TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
argList =list(map(int, input().split())) 
ret = 1
for i in argList:
    ret = ret*i
    if ret >= 10**18 :
        ret = -1
        break
print(ret)

n = int(input())
argList =list(map(int, input().split())) 
ret = 1
if 0 in argList:
    ret = 0
else:

    for i in argList:
        ret = ret*i
        if ret > 10**18 :
            ret = -1
            break
print(ret)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
from functools import reduce
from operator import mul
N = input()
A = map(int, input().split())
res = reduce(mul, A)
if res < 10**18:
	print(res)
else:
	print('-1')

from functools import reduce
from operator import mul
N = input()
A = map(int, input().split())
res = reduce(mul, A)
if res < 10**18:
	print(res)
else:
	print(-1)

N = int(input())
A = input().split()
if '0' in A:
	print(0)
else:
	cutoff = 10**18
	res = 1
	for n in range(N):
		res *= int(A[n])
		if res > cutoff:
			res = '-1'
			break
	print(res)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(int(input()))
ans=1
if 0 in a:
  print(0)
else:
  for i in range(n):
    ans*=a[i]
    if ans>10**18:
      print(-1)
      exit()
  print(ans)
  
  
  
       
       

n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
  print(0)
else:
  for i in range(n):
    ans*=a[i]
    if ans>10**18:
      print(-1)
      exit()
  print(ans)
  

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = map(int,input().split())
ret = 1
if 0 in A:
    print(0)
    exit()
for i in A:
    ret *= i
    if ret > 10**18:
        ret = -1
        break
print(ret)


N = int(input())
A = list(map(int,input().split()))
ret = 1
if 0 in A:
    print(0)
    exit()

for i in A:
    ret *= i
    if ret > 10**18:
        ret = -1
        break
print(ret)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
l = list(map(int,input().split()))
s=1
if 0 in l:
    print(0)
else:
    for i in l:
        s*=i
        print(s)
        if s>10**18:
            s=-1
            break
    print(s)

n=int(input())
l = list(map(int,input().split()))
s=1
if 0 in l:
    print(0)
else:
    for i in l:
        s*=i
        if s>10**18:
            s=-1
            break
    print(s)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys 

input=sys.stdin.readline 

def main():
	n=int(input().strip())
	a=list(map(int,input().strip().split()))
	result =1
	LIMIT =10**18
	if 0 in a:
		print(0)
		sys.exit
	for i in a:
		result *=i
		if result >LIMIT:
			print(-1)
			sys.exit()
		print(result)

if __name__=='__main__':
	main()


import sys
input = sys.stdin.readline

def main():
  n = int(input().strip())
  a = list(map(int, input().strip().split()))
  result = 1
  LIMIT = 10**18
  if 0 in a:
    print(0)
    sys.exit()
  for i in a:
    result *= i
    if result > LIMIT:
      print(-1)
      sys.exit()
  print(result)

main()

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a = int(input())
b = list(map(int,input().split()))
c = 1
if 0 in b:
  print(0)
else:
  for i in range(a):
    c = c * b[i]
    if c > 10 ** 18:
      break
    if c > 10 ** 18:
      print(-1)
    else:
      print(c)


a = int(input())
b = list(map(int,input().split()))
c = 1
if 0 in b:
  print(0)
else:
  for i in range(a):
    c = c * b[i]
    if c > 10 ** 18:
      break
  if c > 10 ** 18:
    print(-1)
  else:
    print(c)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n,*a=map(int,open(0).read().split())
a.sort()
for i in a:
    s *= i
    if s > 1e18:
        print(-1)
        exit()
print(s)

n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
  print(0)
  exit()
for i in a:
    s*=i
    if  s >= 10**18:
        print(-1)
        exit()
print(s)

n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=a
    if  s > 10**18:
        print(-1)
        exit()
print(s)

n,*a=map(int,open(0).read().split())
a.sort()
s=1
for i in a:
    s *= i
    if s > 1e18:
        print(-1)
        exit()
print(s)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    N = int(input('数字を入力して下さい'))
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    total = 1
    for a in A:
        total *= a
        if total > 10 ** 18:
            print(-1)
            return

    print(total)


main()

M = int(input())
N = input().split(' ')
if '0' in N:
    print(0)
else:
    check = False
    total = 0
    f = 0
    N = [int(i) for i in N]
    for i in N:
        if i == 0:
            continue
        total += len(str(i))-1
        if i / 10 ** (len(str(i)) - 1) != 1:
            f += i / 10 ** (len(str(i)) - 1)
        if total + len(str(f)) > 18:
            check = True
            break


    if check:
        print(-1)
    else:
        base = N.pop(0)
        for i in N:
            if i == 1:
                continue
            base *= i
        print(base)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    total = 1
    for a in A:
        total *= a
        if total > 10 ** 18:
            print(-1)
            return

    print(total)


main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = input()
M = list(map(int,input().split()))
    
mult = 1
 
if 0 in A:
  print(0)
  return

for a in M:
    mult *= a
    if mult> 1000000000000000000:
        print(-1)
        
print(mult)

def main():
    N = input()
    M = list(map(int,input().split()))
    
    mult = 1
    
    if 0 in M:
        print(0)
        return
    
    for a in M:
        mult *= a
        if mult>10**18:
            print(-1)
            return
        
    print(mult)
    
main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
A.sort()
total = 1
for i in range(N):
    total *= A[i]
    if 10 ** 18 < total:
        break

if 10**18 < total:
    print("-1")
else:

N = int(input())
A = list(map(int,input().split()))
total = 1
if 0 < A.count(0):
    print(0)
else:
    for i in range(N):
        total *= A[i]
        if 10 ** 18 < total:
            break
    if 10**18 < total:
        print("-1")
    else:
        print(total)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
D=False
ans=1
List=list(map(int,input()split()))
if 0 in List:
  print(0)
else:
  for i in ragne(N):
    ans=ans*List[i]
    if ans>10**18:
      print(-1)
      D=True
      break
  if D==False:
    print(ans)

N=int(input())
D=False
ans=1
List=list(map(int,input().split()))
if 0 in List:
  print(0)
else:
  for i in range(N):
    ans=ans*List[i]
    if ans>10**18:
      print(-1)
      D=True
      break
  if D==False:
    print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np

n=int(input())
a = np.array(list(map(int,input().split())))

ans = np.prod(a)

if(ans >= 10**18):
  ans = -1

print(ans)

n=int(input())
a = list(map(int,input().split()))
ans=1


if(0 in a):
    ans=0
else:
  for i in a:
    ans *= i
    if(ans > 10**18):
      ans = -1
      break

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
from math import prod
n = int(input())

a = list(map(int,input().split()))
new = math.prod(a)
val = pow(10,18)
if new > val:
	print(-1)
else:
	print(new)	 


from math import prod
n = int(input())

a = list(map(int,input().split()))
new = math.prod(a,start=0)
val = pow(10,18)
if new > val:
	print(-1)
else:
	print(new)	 


n = int(input())
a = list(map(int,input().split()))

new = 1
if 0 in a:
	print(0)
	exit()
	
for i in a:
	
	new *= a
	if new > (10**18):
		new = -1
		break
print(new)		
	


from math import trunc
a,b = input().split()
a = int(a)
b = float(b)

print("{}".format(int(a*b)))


n = int(input())
a = list(map(int,input().split()))

new = 1
for i in a:
	
	new *= a
	if new > (10**18):
		new = -1
		break
print(new)		
	


n = int(input())
a = list(map(int,input().split()))
new = 1
if 0 in a:
	print(0)
	exit()
for i in a:
	new *= i
	if new > (10**18):
		new = -1
		break
print(new)		
	


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=input()
flag=0
a=list(map(int,input().split()))
sum=1
for i in a :
    sum*=i
    if(sum>=1e18) :
        flag=1
        break
if(flag==0):
    print(sum)
else : print(-1)

n=input()
flag=0
flag1=0
a=list(map(int,input().split()))
sum=1
a.sort()
for i in a :
    sum*=i
    if(i==0):
        flag1=1
    if(sum>=1e18) :
        flag=1
        break
if(flag==0 or flag1==1):
    print(sum)
else : print(-1)

n=input()
flag=0
flag1=0
a=list(map(int,input().split()))
sum=1
a.sort()
for i in a :
    sum*=i
    if(i==0):
        flag1=1
    if(sum>1e18) :
        flag=1
        break
if(flag==0 or flag1==1):
    print(sum)
else : print(-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
from operator import mul
from functools import reduce
N = int(input())
Aj = [int() for i in input().split()]

ans = reduce(mul, Aj)

if ans > 10**18:
	ans = -1
print(ans)


N = int(input())
Aj = [int() for i in input().split()]

ans = 1
for A in Aj:
	ans *= A
if ans > 10**18:
	ans = -1
print(ans)


N = int(input())
Aj = list(map(int, input()split()))

ans = 1
ng = false
max = 10**18
for A in Aj:
	if A == 0:
		ans = 0
		break
	if ans*A > max:
		ans *= A
print(ans)

N = int(input())
Aj = list(map(int, input().split()))

ans = 1
ng = False
max = 10**18
for A in Aj:
	if A == 0:
		ans = 0
		break
	if ng or ans*A > max:
		ans = -1
		ng = True
	else:
		ans *= A
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())

A = list(map(int,input().split()))
ans = 1
if 0 in A:
  print(0)
  exit()
  
for a in A:
  ans *= a
  if ans >= 10**18:
    print(-1)
    exit()
print(ans)

n = int(input())

A = list(map(int,input().split()))
ans = 1
if 0 in A:
  print(0)
  exit()
  
for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)



Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
S=list(map(int,input().split()))
D=sorted(S)
A=1

for i in range(0,N):
    A=A*D[i]
    if A>=10**18:
        A=-1
        break
print(A)

N=int(input())
S=list(map(int,input().split()))
A=S[0]
for i in range(N):
    A=A*S[i]
if A <10**18:
    print(A)
else:
    print(-1)

N=int(input())
S=list(map(int,input().split()))
A=S[0]
print(S)
for i in range(N):
    A=A*S[i]
print(A)

N=int(input())
S=list(map(int,input().split()))
D=sorted(S)
A=1

for i in range(1,N):
    A=A*D[i-1]
    if A>=10**18:
        A=-1
        break
print(A)

N=int(input())
S=list(map(int,input().split()))
D=sorted(S)
A=1

for i in range(N):
    A=A*D[i]
    if A>10**(18):
        A=-1
        break
print(A)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
length = 1
limit = 10 ** 18
for i in range(N):
    length = length *  A[i]
    if length > limit:
        print('-1')
        break
    if i == N-1:
        print(length)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    length = 1
    limit = 10 ** 18
    if 0 in A:
        print(0)
        return
    for i in range(N):
        length = length *  A[i]
        if length > limit:
            print('-1')
            return
    print(length)
    return
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
l=list(map(int,input().split()))
s=1
d=1
for i in l:
    s=s*i
    if(s>=10**18):
        print(-1)
        d=0
        break
if(d==1):
    print(s)

n=int(input())
l=sorted(list(map(int,input().split())))
s=1
d=1
for i in l:
    s=s*i
    if(s>10**18):
        print(-1)
        d=0
        break
if(d==1):
    print(s)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i
print("-1" if ans>=10**18 else ans)

n = int(input())
a = sorted(list(map(int, input().split())))
ans = 1
for i in a:
    ans *= i
    if ans >= 10**18:
        print("-1")
        break
else:
    print(ans)

n = int(input())
a = sorted(list(map(int, input().split())))
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print("-1")
        break
else:
    print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import math
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
else:
  for i in range(int(N)):
    result *= i
  if(len(str(result)) >= 18):
    print(-1)
  else:
    print(result)

import math
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
else:
  for x in i:
    result *= x
  if(len(str(result)) >= 19):
    print(-1)
  else:
    print(result)

import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  sys.exit()
for x in i:
  result *= x
#  if(len(str(result)) >= 19):
  if(result >= 1000000000000000000):
    print(-1)
    sys.exit()
print(result)


import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  sys.exit()
for x in i:
  result *= x
#  if(len(str(result)) >= 19):
  if(result >= 10**18):
    print(-1)
    sys.exit()
print(result)


import math
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  return
for x in i:
  result *= x
  if(len(str(result)) >= 19):
    print(-1)
    return
print(result)

import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  sys.exit()
for x in i:
  result *= x
  if(len(str(result)) >= 19):
    print(-1)
    sys.exit()
print(result)

import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  sys.exit()
for x in i:
  result *= x
#  if(len(str(result)) >= 19):
  if(result > 10**18):
    print(-1)
    sys.exit()
print(result)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input(""))
k=1
li=list(map(input("").split(" ")))
if "0" in li:
    print("0")
else:
    for i in li:
        k*=int(i)
    if k>1000000000000000000:
        print("-1")
    else:
        print(k)


n=int(input(""))
k=1
li=list(map(int,input("").split(" ")))
if 0 in li:
    print("0")
else:
    for i in li:
        k*=int(i)
    if k>1000000000000000000:
        print("-1")
        break
    else:
        print(k)


n=int(input(""))
k=1
# li=list(map(int,input("").split(" ")))
li=input().split(" ")
if '0' in li:
    print("0")
else:
    for i in li:
        k*=int(i)
        if k>1000000000000000000:
            print("-1")
            break
    else:
        print(k)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
arr=list(map(int,input().split()))
ans=1
for i in arr:
    if ans*i<=10**18:
        ans*=i
    else:
        print(-1)
        return(0)
print(ans)

n=int(input())
arr=list(map(int,input().split()))
ans=1
arr=sorted(arr)
def solve(arr,ans):
    for i in arr:
        ans*=i
        if(ans>10**18):
            return(-1)
        if(ans==0):
            return(0)
    if(ans>10**18):
        return(-1)
    return(ans)
print(solve(arr,ans))

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
count = input()
list = input().split(" ")

i = 0
num = int(list[i])
i += 1
while i>= count:
  num = num * int(list[i])
	
  if num > 10**18:
    print(-1)
    break
    
  i += 1

count = int(input())
list = input().split(" ")
state = False
i = 0
num = int(list[i])
i += 1
limit = 10 ** 18
if "0" in list:
  num = 0
  count = 0

while i < count:
  num = num * int(list[i])

  if num > limit:
    print(-1)
    state = True
    break
    
  i += 1

if not state:
  print(num)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = input().split()
m = 1
k = a.index(“B”)
if k == 0:
    print("0")
else:
    for i in range(n):
        m = m * int(a[i])
        if m > 10**18:
        break
    if m > 10**18:
        print("-1")
    else:
        print(m)

n = int(input())
a = input().split()
m = 1
for i in range(n):
    m = m * a[i]
    if m = 0:
        break
    

if m > 10**18:
    print("-1")
else:
    print(m)

n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

if m == 1:
    for j in range(n):
        m = m * a[j]
        if m > 10**18:
            break
    if m > 10**18:
        print("-1")
    else:
        print(m)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
l = list(map(int, input().split()))
cur = 1
if 0 in l:
    print(0)
    exit()
for i in l:
    cur *= i
    if cur >= 1000000000000000000:
        print(-1)
        exit()
print(cur)

n = int(input())
l = list(map(int, input().split()))
cur = 1
for i in l:
    cur *= i
if cur >= 1000000000000000000:
    print(-1)
else:
    print(cur)

n = int(input())
l = list(map(int, input().split()))
cur = 1
if 0 in l:
    print(0)
    exit()
for i in l:
    cur *= i
    if cur > 1000000000000000000:
        print(-1)
        exit()
print(cur)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
    import numpy as np
    from operator import mul
    from functools import reduce
    N = int(input().strip())
    A = list(map(int,input().split()))
    x = reduce(mul, A)
    if x > 1000000000000000000:
        print("-1")
    else:
        print(x)

    import numpy as np
    from operator import mul
    from functools import reduce
    N = int(input().strip())
    A = list(map(int,input().split()))
    x = reduce(mul, A)
    if x > 1000000000000000000:
        print("-1")
    else:
        print(x)

n = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
  exit()
for num in lis:
  ans *= num
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    limit = 10**18
    ans = 1
    for i in A:
        if A == 0:
            print(0)
            return
        if ans > limit:
            print(-1)
            return
        ans *= A[i]
    print(ans)

main()

def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    limit = 10**18
    ans = 1
    for i in A:
        ans *= i
        if ans > limit:
            print(-1)
            return

    print(ans)

main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
# -*- coding: utf-8 -*-

def main():

    N = int(input())
    A = list(map(int, input().split()))

    ans = 1

    for i in A:
        if A == 0:
            ans = 0
            break
        ans *= i
            if ans > 10 ** 18:
            ans = -1

    print(ans)


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-

def main():

    N = int(input())
    A = list(map(int, input().split()))

    ans = 1

    if 0 not in A:
        for i in A:
            ans *= i
            if ans > 10 ** 18:
                ans = -1
                break

    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = map(int, input().split())

over = False
mul = 1
if 0 in a:
    mul = 0
for a_ in a:
    mul *= a_
    if mul > 10**18:
        mul = -1
        break
print(mul)

n = int(input())
a = list(map(int, input().split()))

over = False
mul = 1
if 0 in a:
    mul = 0
for a_ in a:
    mul *= a_
    if mul > 10**18:
        mul = -1
        break
print(mul)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

try:
    for c in int(n):
        seki = seki * int(kita[n])
    if seki > 10**18:
        print("-1")
    else:
        print(seki)
except:
    print("-1")

#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

try:
    for c in kita:
        if seki < 10**18:
            print("-1")
            break
        else:
            seki = seki * int(c)
            if seki > 10**18:
                print("-1")
            else:
                print(seki)
except:
    print("-1")

#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
a = []
int seki = 1
for c in kita:
    a.append(c)
try:
    for c in a:
        c = c * int(c)
    if c > 10**18:
        print("-1")
    else:
        print(c)
except:
    print("-1")

#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1


for c in kita:
    seki = seki * int(c)
    if seki > 10**18:
        break
    if seki > 10**18:
        print("-1")
    else:
        print(seki)

#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

for c in kita:
    if c == "0":
        kita[0] = "0"

for c in kita:
    seki = seki * int(c)
    if seki > 10**18:
        break

if seki > 10**18:
    print("-1")
else:
    print(seki)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N =int(input())
A_n =list(map(int,input().split()))
ans =1
i = 0

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  elif 0 in A_n is False:
    print(-1)
  else:
    print(0)
else:
  print(ans)

N =int(input())
A_n =list(map(int,input().split()))
ans =1
i = 0

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  elif "0" in A_n is False:
    print(-1)
  else:
    print(0)
else:
  print(ans)

N =int(input())
A_n =list(map(int,input().split()))
ans =1
i = 0

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  if 0 in A_n:
    print(0)
  else:
    print(-1)
else:
  print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
input()
a = map(int, input().split())
ans = 1
from functools import reduce
from operator import mul

for b in a:
    ans = reduce(mul, a)
if(ans > 10 ** 18):
    ans = -1
print(ans)

input()
a = map(int, input().split())
a = list(a)
ans = 1
c = 10 ** 18
if 0 in a:
    print(0)
    exit(0)
for b in a:
    ans *= b
    if(ans > c ):
        print(-1)
        exit(0)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np 
N = int(input())
A = list(map(int, input().split()))
A =np.array(A,dtype=np.int64)

#
ans =0
if 0 in A:
    ans =0:
else:
    ans =np.prod(A)
    if ans >10**18:
        ans =-1
print(ans)

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
#
ans =1
if 0 in A:
    ans =0
else:
    for i in A:
        ans *=i
        if ans >10**18:
            ans =-1
            break
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
li = list(map(int,input().split()))
A = 1
for i in range (N):
 
  A = A * li[i]
  if  A >= 1000000000000000000:
    print(-1)
    break
  else:
    i += 1
print(A)

N = int(input())
li = list(map(int,input().split()))
A = 1
i = 0
B = 0
if 0 in li:
  print(0)
else:
    for i in range (N):
      A = A * li[i]
      if (A > 10**18):
        break
      else: 
        B += 1
        i += 1
    if B == N:
      print (A)
    else:
      print (-1)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys
N = int(input())
A = [int(a) for a in input().split()]

for a in A:
    if(a==0):
        print(0)
        sys.exit()

ans = 1
for a in A:
    ans *= a
    if(ans >= 1000000000000000000) :
        print(-1)
        sys.exit()
print(ans)

import sys
N = int(input())
A = [int(a) for a in input().split()]

for a in A:
    if(a==0):
        print(0)
        sys.exit()

ans = 1
for a in A:
    ans *= a
    if(ans > 1000000000000000000) :
        print(-1)
        sys.exit()
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
li = list(map(int,input().split()))
li.sort()
ans = 1

for i in range(n):
  ans = ans*li[i]
  
  if ans >= 10**18:
    ans = -1
    break

print(ans)

n = int(input())
li = list(map(int,input().split()))
ans = 1

for i in range(n):
  ans = ans*li[i]
  
  if ans >= 10**18:
    ans = -1
    break

print(ans)

n = int(input())
li = list(map(int,input().split()))
ans = 1

for i in range(n):
  ans = ans*li[i]
  
if ans >= 10**18:
  print(-1)
else:
  print(ans)

n = int(input())
li = list(map(int,input().split()))
li.sort()
ans = 1
 
for i in range(n):
  ans = ans*li[i]
  
  if ans > 10**18:
    ans = -1
    break
 
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = map(int, input().split())
total = 1

if 0 in a:
  total = 0
else:
  for i in a:
    total *= i
    if total > 10 ** 18:
      total = -1
      break
print(total)

n = int(input())
a = map(int, input().split())
total = 1

if 0 in a:
  total = 0
else:
  for i in a:
    total *= i
    print(i, total)
    if total > 10 ** 18:
      total = -1
      break
print(total)

n = int(input())
a = list(map(int, input().split()))
total = 1

if 0 in a:
  total = 0
else:
  for i in a:
    total *= i
    if total > 10 ** 18:
      total = -1
      break
print(total)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np

N = int(input())
v = np.arrray(list(map(int, input().split())))

answer = v.prod()

answer = answer if answer <= 10 ** 18 else -1
print(answer)

import functools
import operator
N = 2
v = [1, 0, 2]
limit = 10 ** 18
if 0 not in v:
    answer = functools.reduce(operator.mul, v)
else:
    answer = 0
answer = answer if answer <= limit else -1
print(answer)

import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(operator.mul.v)
answer = answer if answer <= 10 ** 18 else -1
print(answer)

N = int(input())
v = list(map(int, input().split()))
answer = reduce(lambda x,y: x*y, v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(mul.v)
answer = answer if answer <= 10 ** 18 else -1
print(answer)

import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(mul.v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

N = int(input())
v = list(map(int, input().split()))
limit = 10 ** 18

answer = 1
if 0 in v:
  answer = 0
else:
  for i in v:
    answer = answer * i
    if answer <= limit:
      continue
    else:
      answer = -1
      break
print(answer)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map (int, input().split()))
re = 1
for i in range(N):
    re *= A[i]
    if re >= 10**18:
        print(-1)
else:
    print(re)

N = int(input())
A = list(map (int, input().split()))
if 0 in A:
  print(0)
  return
 
re = 1
for i in range(N):
    re *= A[i]
    if re >= pow(10,18):
        print(-1)
        return
else:
    print(re)
    return

N = int(input())
A = list(map (int, input().split()))
re = 1
for i in range(N):
    re *= A[i]
    if re >= pow(10,18):
        print(-1)
       	break
else:
    print(re)

N = int(input())
A = list(map(int,input(). split ()))
if 0 in A:
	print(0)
	return
prod = 1
for a in A:
	prod *= a
	if prod > 1000000000000000000:
		print(-1)
		return

print(prod)

a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    return
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)


a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    return

b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        return
print(b)


a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        return
print(b)


a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    n = int(input())
    arr = list(map(int, input().split()))
    a = 1
    for i in arr:
        a*=i
        if a>10**18:
            print("-1")
            return
    
    print(a)


def main():
    n = int(input())
    arr = list(map(int, input().split()))
    if 0 in arr:
        print(0)
        return
    a = 1
    for i in arr:
        a*=i
        if a>10**18:
            print("-1")
            return
    
    print(a)
main()


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
  if ans >= 10**(18)/a:
    ans = -1
    break
  else:
    ans *= a

if 0 in A:
  print(0)
else:
  print(ans)

N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
  if ans >= 10**(18)//a:
    ans = -1
    break
  else:
    ans *= a

if 0 in A:
  print(0)
else:
  print(ans)

N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in ans:
  if ans >= 10**(18)/a:
	ans = -1
    break
  else:
    ans *= a

if 0 in A:
  print(0)
else:
  print(ans)

N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
  if ans > 10**(18)//a:
    ans = -1
    break
  else:
    ans *= a

if 0 in A:
  print(0)
else:
  print(ans)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np
N=int(input())
lis=list(map(int,input().split()))
lis2=np.array(lis)
ans=np.prod(lis2)
if ans >=10**18:
    ans=-1
print(ans)

n = int(input())
A = [*map(int,input().split())]
A.sort()
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        ans = -1
        break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
#include<bits/stdc++.h>

 
using namespace std;
 
int main(){
  ll n;
  cin>>n;
  ll arr[n];
  ll m =1;
  for(int i=0;i<n;i++){
    cin>> arr[i];
  }
  for(int i=0;i<n;i++){
    m = m* arr[i];
  }
  if(m <=1000000000000000000)
    cout<<m<<endl;
  else
    cout<<'-1'<<endl;
  return 0;
}

def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)

main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
else:
    print(list(A))
    bound = 10 ** 18
    ans = 1
    for a in A:
        ans = ans * a
        if ans > bound:
            ans = -1
            break
    print(ans)

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
else:
    bound = 10 ** 18
    ans = 1
    for a in A:
        ans = ans * a
        if ans > bound:
            ans = -1
            break
    print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split(' ')))
ans=A[0]
for a in A:
    ans*=a
    if (ans > 10**18):
        print(-1)
        exit()
print(ans)



N=int(input())
A=list(map(int,input().split(' ')))
ans=A[0]
for a in A:
    ans*=a
    
if (ans > 10**18):
    print(-1)
else:
    print(ans)

N=int(input())
A=list(map(int,input().split(' ')))
ans=1
calcneeded=1

for a in A:
    if (a == 0):
        print(0)
        exit()
    
    if (calcneeded == 1):
        ans*=a
    
    if (ans > 10**18):
        calcneeded=0

if (ans > 10**18):
    print(-1)
else:
    print(ans)




Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import functools
import operator
import numpy as np
prod = functools.partial(functools.reduce, operator.mul)
N = int(input())
A = list(map(float, input().split()))
#print(A)
output = prod(A)
#print(output)
print(output if abs(output) <= 10**18 else -1)

import numpy as np
N = int(input())
A = list(map(int,input().split()))
#output = np.prod(A)
AA=1
for i in range(N+1):
  #print(A[i])
  AA = AA * A[i]
a = pow(10,18)
print(AA if abs(AA) <= a else -1)

N = int(input())
A = list(map(int,input().split()))
mul = 1
for i in range(N):
  mul *= A[i]
print(mul if mul < 10**18 else -1)

import sys
N = int(input())
A = list(map(int,input().split()))
A.sort()
mul = A[0]
for i in range(1,N):
  mul *= A[i]
  if mul > 10**18:
    print(-1)
    sys.exit()
print(mul)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a =int(input())
l = list(map(int,input().split()))
import numpy as np
sum_log =0
for i in l:
  sum_log+=np.log10(i)
  if sum_log>18:
    print(-1)
    break
#print(sum_log)
print(10**sum_log)
#print(10**18.0)

a =int(input())
l = list(map(int,input().split()))
import numpy as np
sum_log =0
for i in l:
  sum_log+=np.log(i)
  if sum_log>18:
    print(-1)
    break
print(10**sum_log)

a =int(input())
l = list(map(int,input().split()))
l.sort()
import numpy as np
times = 1
for i in l:
  times*=i
  if times>10**18:
    times = -1
    break
print(times)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

for i in range(N):
  if(A[i]==0):
    iszero = True

for i in range(N):
  if(iszero):
    ans = 0
    break
    
  ans *= A[i]
  
  if(ans>=10**18):
    ans = -1

print(ans)

N = int(input())
A = list(map(int, input().split()))
ans =1;

for i in range(N):
  ans *= A[i]
if(ans>=10**18):
  ans = -1

print(ans)

N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

if 0 in A:
  iszero = True
for i in range(N):
  if(iszero):
    ans = 0
    break
  ans *= A[i] 
  if ans>10**18:
    ans = -1
    break

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
x = int(input())

list1 = list(map(int, input().split(" ")))

def calc():
    result = 1
    if 0 in result:
        print("-1")
        exit()
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

calc()

x = int(input())

list1 = list(map(int, input().split(" ")))

result = list1[0]
for i in list1[1:]:
    result *= i

print(result if result < 10**18 else "-1")

x = int(input())

list1 = list(map(int, input().split(" ")))

def calc():
    result = 1
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

x = int(input())

list1 = list(map(int, input().split(" ")))

def calc():
    result = list1[0]
    for i in list1[1:]:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

def main():
    x = int(input())
    list1 = list(map(int, input().split(" ")))
    result = 1

    if 0 in list1:
        print(0)
        return

    for i in list1:
        result *= i
        if result > 10*18:
            print("-1")
            exit()
    print(result)

main()

def main():
    x = int(input())
    list1 = list(map(int, input().split(" ")))
    result = 1

    if 0 in list1:
        print(0)
        return

    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

main()

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
ans = 1
flag = 0
for i in a:
  ans *= i
  if ans >= 10 ** 18:
    flag = 1
    break

if flag == 1:
  print(-1)
else:
  print(ans)

n = int(input())
a = list(map(int, input().split()))
flag = 0
ans = 1

for i in a:
    if i == 0:
        flag = -1
        break
    if ans * i > 10 ** 18:
        flag = 1
    else:
        ans *= i

if flag == 1:
    print(-1)
elif flag == -1:
    print(0)
else:
    print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys
n=int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
for i in range(a):
  ans *= a[i]
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

import sys
n=int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
for i in range(len(a)):
  ans *= a[i]
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np
def main():
    n = int(input())
    A = np.array(list(map(int, input().split())))
    limit = 10 ** 18

    if np.any(A=0):
        print(0)
    else:
        ans = 1
        for i in range(n):
            ans *= A[i]
            if ans > limit:
                print(-1)
                exit()

        print(ans)


if __name__ == "__main__":
    main()


import numpy as np


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    A = np.array(list(map(int, input().split())))
    limit = 10 ** 18

    if np.any(A == 0):
        print(0)
    elif np.any(A > limit):
        print(-1)
    else:
        ans = 1

        for i in range(n):
            ans *= A[i]
            if ans > limit:
                print(-1)
                exit()

        print(ans)


if __name__ == "__main__":
    main()


def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    limit = 10 ** 18
    #print(A)

    if A[-1] == 0:
        print(0)
    elif A[0] > limit:
        print(-1)
    else:
        ans = A[0]
        for i in range(1, n):
            ans *= A[i]
            if ans > limit:
                print(-1)
                exit()

        print(ans)


if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
m=list(map(int,input().split()))
x=1
if 0 in m:
  print(0)
else:
  for y in m:
    x*=y
    if len(str(x))>18:
      print(-1)
  print(x)



n=int(input())
m=list(map(int,input().split()))
x=1
if 0 in m:
  print(0)
else:
  for y in m:
    x*=y
    if x>10**18:
      print(-1)
      break
    else:
      print(x)

n=int(input())
m=list(map(int,input().split()))
x=1
if 0 in m:
  print(0)
else:
  for y in m:
    x*=y
  if len(str(x))>18:
    print(-1)
  else:
    print(x)



x=1
n=int(input())
a=map(int,input().split())
m=list(a)
for x in m:
  if x==0:
    print(0)
  else:
    x*=x
if x<=10**18 and x!=0:
  print(x)
elif x==0:
  break
else:
  print(-1)



n=int(input())
m=list(map(int,input().split()))
x=1
if 0 in m:
  print(0)
else:
  for y in m:
    x*=y
    if x>10**18:
      print(-1)
      break
	else:
      print(x)

n=int(input())
A=list(map(int,input().split()))
a=0
ans=1
if 0 in A:
    ans=0
else:
    for a in range(n):
        ans*=A[a]
        a+=1
        if ans<=10**18:
            continue
        else:
            ans=-1
            break
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
A=[list(map(int,list(input()))) for i in range(N)]

s=1
for i in range(N):
    s = s*A[i]
    if s > 10**18:
        s = -1
        print('-1')
        break
if s != -1:
    print(s)

N=int(input())
A=list(map(int, input().split()))

s=1
if min(A) == 0:
    s = 0
    print(s)
elif max(A) > 10**18:
    s = -1
    print(s)
else:
    for i in range(N):
        s = s*A[i]
        if s > 10**18:
            s = -1
            print('-1')
            break
    if s != -1:
        print(s)

Verdicts: Runtime Error

Accepted