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())
res = 1
for i in range(n):
    a = int(input())
    res = res * a
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

n = int(input())
res = 1
ls = input().split(' ')
list.sort(ls)
if int(ls[0]) == 0:
    print(0)
    exit()
for a in ls:
    res = res * int(a)
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)


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=[int(i) for i in input().split()]
prod=1
for i in range(0,N):
  prod=prod*A[i]
  if(prod>1000000000000000000):
    prod=-1
    break
print(prod)

n=int(input())
A=[int(i) for i in input().split()]
A.sort()
prod=1
for i in range(0,n):
  prod=prod*A[i]
  #print(prod)
  if(prod==0):
      break
  if(prod>1000000000000000000):
    prod=-1
    break
print(prod)


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())
maxi = 10**18
A = list(map(int,input().split()))
ans = 1

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



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



n = int(input())
maxi = 10**18
A = list(map(int,input().split()))
ans = 1
b = max(A)
c = min(A)
if c == 0:
  print(0)
  exit()
else:
  if b >= maxi:
    print(-1)
    exit()

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

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



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



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



n = int(input())
maxi = 10**18
A = list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= A[i]

if ans >= maxi:
  print(-1)
else:
  print(ans)

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



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



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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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 = input()
a = map(int, input().split())
ans = 1
if 0 in a:
  print(0)
  exit()
for i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

n = input()
a = list(map(int, input().split()))
if 0 in a:
  print(0)
  exit()
  
ans = 1
for i in a:
  ans *= i
  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())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
  if(ans>10**18):
    ans = -1
    break
print(ans)

N = int(input())
a = list(map(int,input().split()))
ans = 1
if(0 in a):
  ans = 0
else:
  for i in range(N):
    ans*=a[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=input()
if not N:
	break
a=list(map(int, input().split(" ")))
ans=1
for v in a:
	ans*=v
if 1000000000000000000 < ans:
	ans = -1
print(ans)


while True:
	try:
		N=input()
	except:
		break
	a=list(map(int, input().split(" ")))
	#print(a)
	ans=1
	for v in a:
		ans*=v
		if 1000000000000000000 < ans:
			ans = -1
			break
	if any([v==0 for v in a]):
		ans=0
	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 sys
 
input = sys.stdin.readline
 
n = int(input())
a = list(map(int, input().strip().split()))
if(0 in a):
 print(0)
 return
else:
 ans = 1
 for ai in a:
  ans *= ai
  if(ans > 10**18):
   print(-1)
   return

 print(ans)

import sys
 
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().strip().split()))
    
    if 0 in a:
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if(ans > 10**18):
            print(-1)
            return
    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())
nums = map(int,input().split())
num = 10**18
count = 1
for i in range(n):
	count *= nums[i]

if count < num:
	print(-1)
else:
	print(count)

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

n = int(input())
nums = [int(x) for x in input().split()]
num = 10**18
count = 0
for i in range(n):
	count *= nums[i]

if count < num:
	print(-1)
else:
	print(count)

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


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

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

Verdicts: Runtime Error

Runtime Error

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()))

if 0 in A:
  print(0)
else:
  result=1
  for i in A:
    result*=i
    print(result)

    if result>10**18:
      print(-1)
      break

N = int(input())
A = input().split()

a=int(A[0])
for i in range(N-1):
  a=a*int(A[i+1])
  
if a>10^18:
  print(-1)
else:
  print(a)

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

if 0 in A:
  print(0)
else:
  a=1
  for i in range(N):
    a*=int(A[i])

    if a>10**18:
      print(-1)
      break

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

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

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())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
for i in range(n):
    rs=l[i]*rs
    if (rs>=10**18) or (rs<0):
        rs = -1
        break
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 : 
    print(0)
else:
    for i in range(n):
        rs=l[i]*rs
        if(10**18 / rs < l[i]):
            rs = -1
            break
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 :
    rs=0
else:
    for i in range(n):
        rs=l[i]*rs
        if(10**18 // rs < l[i]):
            rs = -1
            break
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
for i in range(n):
    rs=l[i]*rs
    if rs>10**8:
        rs = -1
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
for i in range(n):
    rs=l[i]*rs
    if rs>=10**18:
        rs = -1
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 : 
    print(0)
else:
    for i in range(n):
        rs=l[i]*rs
        if(10**18 // rs < l[i]):
            rs = -1
            break
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
for i in range(n):
    rs=l[i]*rs
    if (rs>=10**18) or (rs<0):
        rs = -1
        break
print(rs)

n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 :
    rs=0
else:
    for i in range(n):
        if(10**18 // rs < l[i]):
            rs = -1
            break
        rs=l[i]*rs
print(rs)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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):
def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    ans = 1
    for i in a:
        if i == 0:
            ans = 0
            return ans
        ans *= i
        if ans > 10**18:
            ans = -1
            return ans

        return ans

if __name__ == '__main__':
    print(main())

n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
ans = 1
for i in a:
    if i == 0:
        ans = 0
        break
    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):
N = int(input())
a = list(map(int, input().split()))
a.sort()
INF = 10 ** 18
s = 1

print(a)
for i in a:
    s *= i
    if s > INF:
        s = -1
        break

print(s)


N = int(input())
a = list(map(int, input().split()))
a.sort()
INF = 10 ** 18
s = 1

for i in a:
    s *= i
    if s > INF:
        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):
n = int(input())
a = list(map(int, input().split()))

ans = 1

for i in range(n):
    ans *= a[i]
    if ans = 0:
        print(0)
        exit()
    elif 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 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):
from math import log10

N = int(input())
A = list(map(int, input().split()))
s = 1
for a in A:
    if a == 0:
        print(0)
        break
    s *= a
    if log10(s) >= 18:
        print(-1)
        break
else:
    print(s)




from math import log10

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




from math import log10

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




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 collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    
    check=[False for _ in range(n)]
    check[s]=True
    
    queue=deque([s])
    visited_num=1

    
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        
        if len(queue)==0:
            
            
            return color

        now_vertex=queue.popleft()
        
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#n=int(input())
#n,m=input_list()
a=input_list()
ans=1
for i in a:
    ans*=i

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

else:
    print(ans)

from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    
    check=[False for _ in range(n)]
    check[s]=True
    
    queue=deque([s])
    visited_num=1

    
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        
        if len(queue)==0:
            
            
            return color

        now_vertex=queue.popleft()
        
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



n=int(input())
#n,m=input_list()
a=input_list()
ans=1
if 0 in a:
    print(0)
    exit()
for i in a:
    ans*=i
    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):
import sys
n = input()
nums = [int(e) for e in input().split()]

if 0 in nums:
  print('0')
  sys.exit()

ans = 1
s = 10**18

for i in nums:
  ans = ans * i
  if(ans >= s):
    print('-1')
    break


if(ans <= s):
  print(ans)

import sys
n = input()
nums = [int(e) for e in input().split()]

if 0 in nums:
  print('0')
  sys.exit()

ans = 1
s = 10**18

for i in nums:
  ans = ans * i
  if(ans > s):
    print('-1')
    break


if(ans <= s):
  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 = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans > 10**18+1:
        print(-1)
        exit()
    elif ans == 0:
        print(0)
        exit()
print(int(ans))

import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        sys.exit()
    elif ans == 0:
        print(0)
        sys.exit()
print(int(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 = list(map(int, input().split()))

multi = 1
for i in range(n):
    multi = multi * a[i]
    if multi > 100000000000000000:
        print(-1)
        break
if multi <= 100000000000000000:
    print(multi)

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

multi = 1
if min(a) == 0:
    print(0)
else:
    for i in range(n):
        multi = multi * a[i]
        if multi > 1000000000000000000:
            print(-1)
            break
    if multi <= 1000000000000000000:
        print(multi)

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 range(N):
    ans *= A[i]
    if ans >= 1000000000000000000:
        print(-1)
        exit()

print(ans)


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

ans = 1
for i in range(N):
    if A[i] == 0:
        print(0)
        exit()

for i in range(N):
    ans *= A[i]
    if ans > pow(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())
vec=list(map(int,input().split()))
vec.sort()
print(vec)

if(0 in vec):
    print(0)
else:
    res = 1
    for v in vec:
        res *= v
        if(res > 10**18):
            res = -1
            break

    print(res)

N=int(input())
vec=list(map(int,input().split()))
vec.sort()


if(0 in vec):
    print(0)
else:
    res = 1
    for v in vec:
        res *= v
        if(res > 10**18):
            res = -1
            break

    print(res)

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=[input().split()]
x=1
for i in range(n):
    x*=int(a[i])
if x>10**18:
    print("-1")
else:
    print(x)

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

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()))
X = 10**18
ans = 1
for i in range(N):
  ans = ans * A[i]
  if ans >= X:
    ans = -1
    break
print(ans)

N = int(input())
A  = list(map(int, input().split()))
X = 10**18
ans = 1
if 0 in A:
  ans = 0
else:
  for i in range(N):
    ans = ans * A[i]
    if ans > X:
      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()))
s = 1

if '0' in a:
    s = 0
else:
    for i in range(n):
        s = s * a[i]
    if s > 10 ** 18:
        s = -1
        break
print(s)

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

if 0 in a:
    s = 0
else:
    for i in range(n):
        s = s * a[i]
        if s > 10 ** 18:
            s = -1
            break
print(s)

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):
X, Y = map(int, input().split())

result = "No"
for i in range(X + 1):
    if 2 * i + (X - i) * 4 == Y:
        result = "Yes"

print(result)

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

result = 1
if 0 in A:
    print("0")
else:
    for a in A:
        result *= a
        if result > 10**18:
            result = -1
            break
    print(result)

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
# Your code here!

from collections import deque

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

for i in range(N - 1):
    ans *= A.popleft()
if ans >= pow(10, 18):
    print(-1)
else:
    print(ans)

# coding: utf-8
# Your code here!

from collections import deque

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

for i in range(N - 1):
    ans *= A.popleft()
if ans >= pow(10, 18):
    print(-1)
else:
    print(ans)

# coding: utf-8
# Your code here!

from collections import deque

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

if 0 in A:
    print(0)
    exit()

for i in range(N - 1):
    ans *= A.popleft()
    if ans > pow(10, 18):
        print(-1)
        exit()
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=int(input())
A=list(map(int,input().split()))
l=[]

for i in A:
  l.append(math.log10(A[i]))
  
if sum(l)<18:
  print(int(10**sum(l)))
else:
  print(-1)

import math

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

if 0 not in A:
  for i in A:
  l.append(math.log10(A[i]))
  if sum(l)<18: 
    print(int(10**sum(l)))
  else:
    print(‘-1’)
else:
  print(‘0’)

import.math

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

for _ in A:
  l.append(math.log10(A))
  
if sum(l)<18:
  print(math.exp(sum(l)))
else:
  print(-1)

import math

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

if 0 not in A:
  for i in A:
    l.append(math.log10(A[i]))
  if sum(l)<18: 
    print(int(10**sum(l)))
  else:
    print(str(-1))
else:
  print(str(0))


import numpy as np

N=int(input())
A=list(map(int,input().split()))
T=np.prod(A)
 
if T<10**18: 
    print(T)
else:
    print(str(-1))

N=int(input())

for i in range(N):
  ans*=int(input())
  if ans>10**18:
    break
    print(-1)

print(ans)


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

if 0 in a:
  print(0)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

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):
n = int(input())
k = list(map(int, input().split()))
import collections
c = collections.Counter(k)
re = 1
if c[0] == 0:
  for i in range(n):
    re = re * k[i]
    if re >= 10**18:
      print(-1)
      exit()
  print(re)
else:
  print(0)

n = int(input())
k = list(map(int, input().split()))
import collections
c = collections.Counter(k)
re = 1
if c[0] == 0:
  for i in range(n):
    re = re * k[i]
    if re > 10**18:
      print(-1)
      exit()
  print(re)
else:
  print(0)

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()))
ans = 1
for i in A:
    ans *= i
if ans >= 10**18:
    print(-1)
else:
    print(ans)

n = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
    exit()
for i in A:
    ans *= 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)
    exit()
for i in A:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
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):
n = int(input())
a = list(map(int,input().strip().split()))
p = 1
j = 10**18
for i in range(n):
	p = p * a[i]
    if p > j:
      print(-1)
      break
    elif i = n-1:
      ptint(p)


n = int(input())
a = list(map(int,input().strip().split()))
p = 1
j = 10^18
for i in range(n):
	p = p * a[i]
    if p > j:
      print(-1)
      break
    elif i = n-1:
      ptint(p)


n = int(input())
a = list(map(int,input().split()))
i = 0
p = 1

if 0 in a:
    print("0")
else:
    while i < n:
        p *= a[i]
        if p > 10**18:
            break
        i += 1
    if p <= 10**18:
        print(p)
    else:
        print("-1")

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):
import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if res == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)


import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if a == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)


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 = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
limit = 10**18
for i in a:
    ans*=i
    if ans > limit:
        print(-1)
        exit()
print(ans)

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

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

Verdicts: 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 solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1
 
    for i in a:
        ans *= i
      	if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())


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

    ans = 1
    if 0 in a: return 0
    for i in a:
        ans *= i
        if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())


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):
A,B = map(float,input().split())
B = B*100
print(int(A*B/100))

import sys
N = int(input())
An = []
mul = 1

An = list(map(int,input().split()))
if An.count(0) > 0:
    print("0")
    sys.exit()

for i in An:
    mul *= i
    if mul > 10**18:
        print("-1")
        sys.exit()

if mul <= 10**18:
    print(mul)
    

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):
def main():
    n = int(input())

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

    if 0 in a:
        print(0)
        return

    ans = 1
    for tmp in a:
        ans *= tmp
        if (ans > 1e18) :
            print(-1)
            return

    print(ans)

main()


def main():
    n = int(input())

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

    if 0 in a:
        print(0)
        return

    ans = 1
    for tmp in a:
        ans *= tmp
        if (ans > 1e18) :
            print(-1)
            return

    print(ans)

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):

def solve():
  n=int(input())
  a=list(map(int,input().split()))
  if 0 in a:
    print(0)
  f=1  
  for i in a:
    f*=i
    if f>100000000000000000:
      print(-1)
      return 
  print(f)
solve()  
    

n=int(input())
a=list(map(int, input().split()))
f=1
for i in range(n):
  f*=a[i]
c=0
while f>0:
  c+=1
  f/=10;
if c>19:
  print(-1)
else:
  print(f)

def solve():
    n=int(input())
    a=list(map(int,input().split()))
    f=1
    if 0 in a:
        f=0
    for i in a:
        f*=i
        if f>1000000000000000000:
            print(-1)
            return 
    print(f)
solve()    

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):
MAX = pow(10,18)
n = int(input())
A = list(map(int,input().split()))

if 0 in A:
    print(0)
else:
    ans = 1
    digit = 0
    flg = True
    for a in A:
        digit += len(str(a))
        ans *= a
        if digit > 18:
            print(-1)
            break
        flg = False
    if flg:
        if ans > MAX:
            print(-1)
        else:
            print(ans)


MAX = pow(10,18)
n = int(input())
A = list(map(int,input().split()))

if 0 in A:
    print(0)
else:
    ans = 1
    digit = 0
    flg = True
    for a in A:
        digit += len(str(a))
        ans *= a
        if digit > 18:
            print(-1)
            flg = False
            break
    if flg:
        if ans > MAX:
            print(-1)
        else:
            print(ans)


MAX = pow(10,18)
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 > MAX:
            print(-1)
            return

    print(ans)

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 = int(input())
a = [int(i) for i in input().split()]
ans = 1
if 0 in a:
	print(0)
	exit()
for i in range(n):
	ans += a[i]
	if ans > 10 ** 18:
		print(-1)
		exit()
print(ans)n = int(input())
a = [int(i) for i in input().split()]
ans = 1
if 0 in a:
	print(0)
	exit()
for i in range(n):
	ans += a[i]
	if ans > 10 ** 18:
		print(-1)
		exit()
print(ans)

n = int(input())
a = [int(i) for i in input().split()]
ans = 1
if 0 in a:
	print(0)
	exit()
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):
def main():
  n = int(input())
  li = list(map(int,input().split()))
  li.sort()
  ans = 1
  for i in range(n):
    ans *= li[i]
    if ans > (10 ** 18):
      print(-1)
      exit()
    print(ans)


if __name__ == '__main__':
  main()

import math

def main():
  a, b = input().split()
  a = int(a)
  b = float(b)
  c = int(b)
  d = (b - c) * 100
  ans_a = a * c
  ans_b = (a * d) // 100
  ans = math.floor(ans_b) + ans_a
  print(ans)
 
 
if __name__ == '__main__':
  main()

def main():
  n = int(input())
  ans = 0
  for i in range(n):
    ans *= int(input())
  if ans >= 10 ** 18:
    print(-1)
  else:
    print(ans)


if __name__ == '__main__':
  main()

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


if __name__ == '__main__':
  main()

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

if __name__ == '__main__':
  main()

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


if __name__ == '__main__':
  main()

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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
for i in range(N):
    if a.index(0):
        ans = 0
        break
    ans = ans * a[i]
    if ans > 10**18:
        ans = -1
        break
print(ans)

N = int(input())

a = list(map(int, input().split()))
ans = 1
if 0 in a:
    ans = 0
else :
    for i in range(N):
        ans = ans * a[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):
res = 1
for a in map(int, input().split()):
  res *= a
  if res > 10 ** 18:
    print(-1)
    break
else:
  print(res)

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

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()))

cumprod=1
for i in range(n):
    cumprod *= a[i]
    print(int(cumprod))
    if cumprod > 10**18:
        print(-1)
        exit()
print(int(cumprod))

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

if 0 in a:
    print(0)
    exit()

cumprod=1
for i in range(n):
    cumprod *= a[i]
    if cumprod > 10**18:
        print(-1)
        exit()
print(cumprod)


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 functools
import operator

n=int(input())
a=[int(i) for i in input().split()]

b=functools.reduce(operator.mul,a)

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

import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
b = np.prod(a)


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

n=int(input())
a=[int(i) for i in input().split()]
b=1

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


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

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 = input()
s = []
ans = 1

for _ in range(n):
    s.append(map(int,input()))

if 0 in s:
    print(0)
else:    
    for i in range(n+1):
        ans *= s[i]

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

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

n = input()
s = []
ans = 1

for _ in range(n):
    s.append(map(int,input()))

if "o" in s:
    print(0)
else:
    for i in range(n+1):
       ans *= s[i]
       if ans > 10**18:
           ans = -1
           break
    print(ans)

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

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


n = input()
s = []
ans = 1

for _ in range(n):
    s.append(map(int,input()))

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


n = int(input())
a = [int(n) for n in input().split()]
ans = 1

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

n = int(input())
a = [int(n) for n in input().split()]
ans = 1

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


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

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

n = int(input())
a = [int(n) for n in input().split()]
ans = 1

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

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

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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,input().split()))
count=1
if 0 in a:
  print(0)
  exit(0)
for i in a:
    count*=i
	if count>10**18:
    	print(-1)
        exit(0)
else:
    print(count)


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


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


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


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


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


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


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


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


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


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


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


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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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):

using namespace std;
int n;
int numbers[110];
int result;
int main() {
  cin >> n;
  for(int i; i<n; i++){
    cin >> numbers[i]
  }
  for(int i; i<sizeof(numbers)/sizeof(array[0]); i++){
    if(i == 0){
      cout << "0";
    }else{
      result *= numbers[i]
    }
  }
  if(result > pow(10,18.0)){
    cout << "-1"
  }else{
    cout << result
  }
}

n = int(input())
a = [i for i in map(int, input().split())]
 
if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

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):
def main():
N=int(input())
A=list(map(int,input().split()))
if A is 0:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)  
main()  
  


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

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


def main():
    N=int(input())
    A=list(map(int,input().split()))
    if 0 in A:
      print('0')
      return
    p=1
    for i in A:
      p=p*i
      if p>1000000000000000000:
        print(-1)
        return
    print(p)    
main()  
  

Verdicts: 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()))
prod = 1

if 0 in a:
    print(0)
    exit()

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

print(prod)


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

for i in a:
    prod *= i

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


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

if 0 in a:
    print(0)
    exit()

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

print(prod)


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):
ans = 1
for i in a:
    ans *= i
    if ans > pow(10,18):
        print(-1)
        break
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
if 0 in a:
    print(0)
else:

    ans = 1
    for i in a:
        ans *= i
        if ans > pow(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())

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

x = functools.reduce(operator.mul, A)
y = 10**18


if x > y:
    print("-1")
else:
    print(x)

N = int(input())
A = list(map(int, input().split()))
x = 1
y = 10**18

x = np.prod(A)
if x > y:
    print("-1")
else:
    print(x)


N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 1
rec = True
for i in range(N):
    ans = ans * l[i]
    if ans > 10**18:
        rec = False
        break

if rec:
    print(ans)
else:
    print('-1')

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())
ans = 1
INF = 10**18
*a, = map(int, input().split())

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

N = int(input())
ans = 1
INF = 10**18
*a, = map(int, input().split())

if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        if ans>INF:
            print(-1)
            break
    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):
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

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

N = int(input())
A = list(map(int, input().split()))
 
for i in N:
  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 N:
  ans *= A[i]
  
  if ans > 10 ** 18:
  print(-1)
  return 
  

  
print(ans)

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

for i in N:
  ans *= A[i]
  
print(ans)

N = int(input())
A = list(map(int, input().split()))
 
ans = 1
 
for i in A:
  ans *= i
  
  if ans > 10 ** 18:
  print(-1)
  return 
  
 
  
print(ans)

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

main()      

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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
a.sort()
ans = 1
for aa in a:
    ans *= aa
    if ans > 10 ** 18:
        print(-1)
        exit()
print(len(str(ans)))


def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    ans = 1
    for aa in a:
        ans *= aa
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted