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):
from sys import stdin
from functools import reduce 


inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) <= 1e18 or x < 0 or y < 0  else (X * y)), inputs)

print(output)

from sys import stdin
from functools import reduce 


inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) > 1e18 or x < 0 or y < 0  else (x * y)), inputs)

print(output)

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

N = int(input())
*A, = map(int, input().split())
aa = sum(A)
if aa >= 10 ** 18:
    print(-1)
else:
    print(aa)

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

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

Verdicts: 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):
import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
a = np.array(a_list)
total = a.prod()
if total >= 10**18:
    print(-1)
else:
    print(int(total))

import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
total = np.prod(a_list)
print(a_list)

if total > 1000000000000000000 or total <0:
    print('-1')
else:
    print(int(total))

import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
total = np.prod(a_list)
print(a_list)

if int(total) > 1000000000000000000:
    print('-1')
elif int(total) < 0:
    print('-1')
else:
    print(int(total))

a = int(input())
li = list(map(int,input().split()))
total = 1
i = 1
for i in range(a):
    total = total*li[i]
    if total > 1000000000000000000:
        total = -1
        break
for i in range(a):
    if li[i] == 0:
        total = 0
 
print(total)

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):
def main():
    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)
main()


def main():
    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 > 10000000000000000000:
            print(-1)
            return
        print(prod)
main()


def main():
    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)
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())
p = [int(i) for i in input().split()]
ans = 1

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

N = int(input())
p = [int(i) for i in input().split()]
ans = 1

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

N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  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):
N = int(input())
A = [int(x) for x in input().split()]

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

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

print(ans)


N = int(input())
A = [int(x) for x in input().split()]

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

ans = A[0]
for i in range(1, N):
    ans *= A[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):
_,*a=map(int,open(0).read().split());z=1
for i in a:
 if i>=1e18/z:z=-1;break
 z*=i
print(0 if 0in a else z)

input();a=sorted(map(int,input().split()));z=1
for i in a:
 z*=i
 if z>1e18:z=-1;break
print(z)

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 i in range(1,n):
    ans*=a[i]
print(ans if ans<10**18 else -1)

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

if mult > 1e18:
  print(mult)
else:
  print(-1)

N = int(input())
A = list(map(int,input().split()))
mult = 1
 
if 0 in A:
  mult = 0
  
for i in range(N):
  mult *= A[i]
  if mult > 1e18:
    print(-1)
    break

if mult <= 1e18:
  print(mult)

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(' '))
result = 1
if min(nums) == 0:
    print(0)
else:
    for i in nums:
        result *= i
    if result > 10**18:
        print(-1)
    else:
        print(result)

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

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())
arr = input()   
l = list(map(int,arr.split(' ')))
sum = 1
for i in l:
  sum *= i
  if sum >= 1e18:
    break
if sum < 1e18:
  print(sum)
else:
  print(-1)

import math
n = int(input())
arr = input()   
l = list(map(int,arr.split(' ')))




#     print(-1)
#     break
sum = math.prod(l)
if sum < 1e18:
  print(sum)
else:
  print(-1)

n = int(input())
arr = input()   
l = list(map(int,arr.split(' ')))
sum = l[0]
for i in range(1,n):
  sum *= l[i]
  if sum >= 1e18:
    print(-1)
    break
if sum < 1e18:
  print(sum)

n = int(input())
arr = input()   
l = list(map(int,arr.split(' ')))
sum = 1
for i in l:
  if len(str(i)) + len(str(sum)) < 18:
    sum *= i
  if sum >= 1e18:
    break
if sum < 1e18:
  print(sum)
else:
  print(-1)


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


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):
a=int(input())
b=map(int,input().split())
b=[int(i) for i in b]
c=1
for i in b:
    c=c*i
if(c<10**18):
    print(c)
else:
    print(-1)


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

if 0 in b:
  print(0)
  exit()
c=1
for i in b:
    c*=i
	if(c>10**18):
    	print(-1)
        exit()
     
print(c)


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

c=1
for i in b:
    c*=i
if(c<10**18):
    print(c)
else:
    print(-1)


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

if 0 in b:
  print(0)
  exit()
c=1
for i in b:
    c*=i
    if(c>10**18):
        print(-1)
        exit()
     
print(c)


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

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

val = numpy.prod(A)

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


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

vt = 1

for v in A:
    if v == 0:
        print(0)
        exit(0)
    if v > 10**18:
        print(-1)
        exit(0)
    vt *= v
    if vt > 10**18:
        print(-1)
        exit(0)

print(vt)
    


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 = [int(_c) for _c in input().split(" ")]

res = 1
for a in a_list:
    res = res * a

if res > 10 ^ 18:
    print(-1)
else:
    print(res)

N = int(input())
a_list = [int(_c) for _c in input().split(" ")]
a_list = sorted(a_list)

res = 1
flg = False
for a in a_list:
    res = res * a
    if res > 10 ** 18:
        flg = True
        break

if flg:
    print(-1)
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()))
ans=False
f=True
for i in a:
    ans*=i
    if ans>10**18:
        f=True
        break
if f:
    print(-1)
else:
    print(ans)

n=int(input())
a=sorted(list(map(int, input().split())))
ans=1
f=True
for i in a:
    ans*=i
    if ans>10**18:
        f=False
        break
if f:
    print(ans)
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):
from operator import mul
from functools import reduce

def main ():
  count = int(input())
  c = list(map(int,input().split()))
  print(c)

  if 0 in list:
    print(0)

  a = reduce(mul, list)

  if a > 1000000000000000000:
    print('-1')
  else:
    print(a)

main()

from operator import mul
from functools import reduce

def main ():
  count = int(input())
  c = list(map(int,input().split()))
  print(c)

  if 0 in list:
    print(0)

  a = reduce(mul, list)

  if a > 1000000000000000000:
    print(-1)
  else:
    print(a)

main()

def main ():
  count = int(input())
  c = list(map(int,input().split()))

  if 0 in c:
    print(0)
    return

  result = 1
  for a in c:
    result *= a
    if result > 1000000000000000000:
      print(-1)
      return

  print(result)

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

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

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

limit = 10**18

result = 1
for value in A:
    result *= value
    if result > limit:
        result = -1
        break

print(result)

N = int(input())

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

if 0 in A:
    print(0)
    return
    
limit = 10**18

result = 1
for value in A:
    result *= value
    if result > limit:
        result = -1
        break

print(result)

N = int(input())

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

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

limit = 10**18

result = 1
for value in A:
    result *= value
    if result > limit:
        result = -1
        break

print(result)

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

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

num = list(map(int,input().split()))
for l in range(len(num)):
    ans *= num[l] 
if ans < 10**18:
    print(ans)
elif ans >= 10**18:
    print(-1)

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

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

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

Verdicts: Runtime Error

Wrong Answer

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

mul = 1
if 0 in set(a): print(0)
else:
    iter = 0
    for i in range(n):
        mul *= a[i]
        if mul < 1e18:
            print(-1)
            break
print(mul)    

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

mul = 1
for i in range(n):
    mul *= a[i]
print(mul if mul < 1e18 else -1)

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

mul = 1
if 0 in set(a): mul = 0
else:
    iter = 0
    for i in range(n):
        mul *= a[i]
        if mul > 1e18:
            mul = -1
            break
print(mul)    

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())
ans = 1
for i in range(n):
    a = int(input())
    if ans * a > 1e18:
        ans = -1
    else:
        ans *= a

print(ans)

n = int(input())
l = map(int, input().split())
ans = 1
for a in l:
    if ans * a > 1e18:
        ans = -1
    elif ans != -1 or a == 0:
        ans *= a

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

keta = 0
for c in range(N):
    keta += len(str(A[c])) - 1

if keta >= 18:
    print("-1")
else:
    ans = 1
    for c in range(N):
        ans *= A[c]
    if ans > 10 ** 18:
        print("-1")
    else:
        print(ans)

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

count = 1

if A.count(0) != 0:
    print("0")
else:
    for c in A:
        count *= c
        if count > 10 ** 18:
            print("-1")
            break
            
    else:
        print(count)

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 = []
a = map(int,input().split())
ans = 1
for val in a:
    ans *= val
if ans > 10**18:
    print("-1")
    break
else:
    print(ans)

n = int(input())
a = []
a = map(int,input().split())
a = sorted(a)
ans = 1
for val in a:
    ans *= val
    if ans > 10**18:
        print(-1)
        break
else:
    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()))
Ans=1

for i in range(N):
  if A[i]==0:
    Ans=0
    break
  Ans=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):
  if A[i]==0:
    Ans=0
    break
  Ans=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=Ans*A[i]

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

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

A.sort()
for i in range(N):
	Ans=Ans*A[i]

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

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

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

print(ans)


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

N = input()
x = list(map(int,input().split()))
 
z = 1	
for a in x:
  z *= a
  if z >= 10**18:
    print(-1)
    break
  
if z<10**18:
  print(z)

N = input()
x = list(map(int,input().split()))
 
z = 1
if 0 in x:
  print(0)

for a in x:
  z *= a
  if z > 1000000000000000:
    print(-1)
    return
  
print(z)

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

z = 1	
for a in x:
  z *= a
  if z >= 10**18:
    break
    print(-1)
  
if z<10**18
  print(z)

N = input()
x = list(map(int,input().split()))
 
z = 1	
for a in x:
  z *= a
  
if z<10**18 :
  print(z)
else:
  print(-1)

import sys
N = input()
x = list(map(int,input().split()))
 
z = 1
if 0 in x:
  print(0)
  sys.exit()
  
for a in x:
  z = a*z
  if z > 10**18:
    print(-1)
    sys.exit()
  
print(z)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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())
sum = 1
a = list(map(int, input().split()))
for i in range(n):
  sum = sum*a[i]
  
if sum > 1e10:
  print(-1)
else:
  print(sum)

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

def prod(a):
    if 0 in a:
        return 0
    p = 1
    for ai in a:
        if p * ai <= 10**18:
            p *= ai
        else:
            return -1
    return p

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

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

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


prod = 1
overflow_flag = False

for a in As:
    prod *= a

    if prod > 10*18:
        overflow_flag = True
        break

if overflow_flag or prod > 10**18:
    print("-1")
else:
    print(prod)


N = int(input())

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


prod = 1
overflow_flag = False

if 0 in As:
    print(0)
else:
    for a in As:
        prod *= a

        if prod > 10**18:
            overflow_flag = True
            break

    if overflow_flag:
        print("-1")
    else:
        print(prod)


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()))
import functools
import operator
result = functools.reduce(operator.mul, A[0:N])
print(-1 if result >=10**18 else result)

N = int(input())
A = list(map(int, input().split()))
r=1
for n in A:
    r=r*n
    if r==0:
        print(0)
    elif r>10**18:
        print(-1)
    else:
        print(r)

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

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()))
thres = 10**8
res = A[0]
for i in range(N-1):
   res *= A[i+1]
   if res > thres:
       res = -1
print(res)

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

ans = 1

min_A = min(A)
A = sorted(A, reverse=True)

if min_A == 0:
    print(0)
    exit()

for a in A:
    ans *= a
    print(f"{ans=}")
    if ans > 10 ** 18:
        break

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


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

ans = 1

min_A = min(A)
A = sorted(A, reverse=True)

if min_A == 0:
    print(0)
    exit()

for a in A:
    ans *= a
    if ans > 10 ** 18:
        break

if ans > 10 ** 18:
    print(-1)
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):
defmain():N =int(input())A =list(map(int,input().split()))if0inA:print(0)returnprod = 1forainA:prod *= aifprod > 1000000000000000000:print(-1)returnprint(prod)main()

def main():
	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)


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_list=list(input().split())
a=int(n_list[0])
b=float(n_list[1])
ans=a*b
print(int(ans))

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

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

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

a= x[1:]
a2= x[:1]
for i in a:a2.append(a2[-1]*i)
  
print(a2[-1])

lenght = int(input())
 
x = list(map(int,input().split()))
x.sort(reverse=True)
check = False

if x[-1]==0:
  print(0)
else:
  first_value = 1
  for val in x:
    first_value *= val
    if first_value > 1e18:
      check=True
      break
  if check:
    print(-1)
  else:
  	print(first_value)

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 multiply(myList) : # define function to calculate the result of multiplication 
      
    
    result = 1 
    for x in myList: 
         result = result * x  
    return result  

N = int(input())

B = list(map(int, input().split(' ')))
A = []

for i in range (0,N):
    c = B[i]
    A.append(c)

ans = multiply(B)

if ans < pow(10,18):
    print(ans)
else:
    print(-1)

n = int(input())
a = list( map (int , input().split() ) )
a.sort()
ans = 1
for i in range(n):
    ans*=a[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):
def main():
	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 > 1000000000:
     		print(-1)
            return
    print(prod)
main()

def main():
  n = int(input())
  v = list(map(int, input().split()))

  if 0 in v:
    print(0)
    return
  
  prod = 1
  for i in v:
    prod *= i
    if(prod > 1000000000000000000):
      print(-1)
      return
  print(prod)

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())
b = [int(x) for x in input().split()]
r = 1
max = 10**18

for i in b:
  r *= i
  
r = -1 if r >= max else r
print(r)

n = int(input())
l = [int(x) for x in input().split()]

if 0 in l:
    r=0
else:
    r = 1
    for x in range(n):
        r = r * l[x]
        if r > 10**18:
            r=-1
            break
  
print(r)

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 ()))
if 0 in A:
	print(0)
	return
prod = 1
for a in A:
	prod *= a
	if prod > 1000000000000000000:
		print(-1)
		return
print(prod)

def main ():
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)
main ()

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

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())
a = list(map(int,input().split()))
c = 1

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

for i in range(len(a)):
    c = c * a[i]
    if c > pow(10,18):
        print(-1)
        exit(0)

print(c)

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

for i in range(len(a)):
    c = c * a[i]
    if c >= pow(10,18):
        print(-1)
        exit(0)

print(c)

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

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

for i in range(len(a)):
    c = c * a[i]
    if c > pow(10,18):
        print(-1)
        exit(0)

print(c)

Verdicts: 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):
def main():
    _ = input()
    lst = list(map(int, input().split()))
    ans = 1

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


if __name__ == "__main__":
    main()


def main():
    _ = input()
    lst = list(map(int, input().split()))
    ans = 1

    if 0 in lst:
        print(0)
        exit()
    for i in lst:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    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):
import sys
O = pow(10, 18)
N = int(input())
L = list(map(int, input().split()))
M = 1

for i in range(N):
    if L[i - 1] == 0:
        print(0)
        sys.exit()
    else:
        break

for i in range(N - 1):
    M = M * L[i]
    if O < M:
        print(-1)
        sys.exit()
    else:
        continue
print(M)

import sys
O = pow(10, 18)
N = int(input())
L = list(map(int, input().split()))
M = 1

if 0 in L:
    print(0)
    sys.exit()

for i in range(N):
    M = M * L[i]
    if O < M:
        print(-1)
        sys.exit()
    else:
        continue
print(M)

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

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

print(tar)

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

tar = reduce(lambda x, y: x*y, values)

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


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

tar = 1
for i in range(A):
    tar *= i

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


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

tar = reduce(lambda x, y: x*y, A)

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


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

tar = 1
for i in range(A):
    tar *=  i

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



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

print(tar)


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

# 169 B
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
tmp_ans = 0
for i in range(N):
    if len(str(A[i])) > 1:
        tmp_ans += (len(str(A[i])) -1)
        print(tmp_ans)


if tmp_ans > 18:
    print(-1)
else:
    for j in range(1, N):
        ans *= A[j]
    print(ans)

# 169 B
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
tmp_ans = 1
for i in range(N):
    if len(str(A[i])) > 1:
        tmp_ans += (len(str(A[i])) -1)
        print(tmp_ans)


if tmp_ans > 18:
    print(-1)
else:
    for j in range(1, N):
        ans *= A[j]
    print(ans)

# 169 B
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > 10**18:
        print(-1)
        break
else:
    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())
arr = [int(x) for x in input().split()]
ans = arr[0]
for i in range(1,n):
	ans *= arr[i]
	if ans>1000000000000000000:
		ans = -1
        break
print(ans)


N = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
prod = 1
for i in arr:
	prod *= i
	if prod>10**18:
		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())
    A = sorted([int(i) for i in input().split()])
    res=1
    for x in A:
        res = res*x
        if res > 10 ** 18:
            res = -1
            break
    print(res)

res = 1

A = int(input())
N = sorted([int(x) for x in input().split()])

for x in N:
    res *= x
    if res > pow(10, 18):
        res = -1
        break

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

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

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()))
def f():
  if a in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

    if b<=10**8:
      print(b)
    else: print(-1)

f()

n=int(input())
a=list(map(int,input().split()))
def f():
  if 0 in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

      if b>10**8:
        print(-1)
        return
   
    print(b)

f()

n=int(input())
a=list(map(int,input().split()))
b=1
for i in range(0,n):
  b*=a[i]

if b<=10**8:
  print(b)
else: print(-1)

n=int(input())
a=list(map(int,input().split()))
def f():
  if 0 in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

      if b>10**8:
        print(-1)
        return
   
  print(b)

f()

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

n=int(input())
a=list(map(int,input().split()))
def f():
  if 0 in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

    if b<=10**8:
      print(b)
    else: print(-1)

f()

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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()))
B = 1

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

N = int(input())

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

res = A[0]

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

for i in range(N-1):
    res = res*A[i+1]
    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):
a = list(map(int, input().split()))

result = 1
for a_i in a:
    result *= a_i

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

def main():
    _ = input()
    a = list(map(int, input().split()))

    result = 1
    for a_i in a:
        if a_i == 0:
            return 0

    for a_i in a:
        result *= a_i

        if 10**18 < result:
            return -1

    return result


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


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

def main(A):
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
    print(prod)
    
main(A)

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

def main(A):
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
    
main(A)


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 main():
    n = input()
    a = list(map(int,input().split()))
    x = 1
    for i in range(len(a)):
        b = a[i]
        if b == 0:
                print(0)
                return
        x *= b
        if x > 10^18:
            print(-1)
            return
    print(x)
    return

main()

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

if 0 in x :
    print(0)
else :
    ans = 1;
    for i in range(n - 1):
        ans *= x[i]
        if ans > 1000000000000000000:
            print(-1)
            continue
    print(ans)

n = int(input())
x = list(map(int, input().split()))
ans = 1 ;
for i in range(n-1) :
    ans *= x[i]
if ans > 1000000000000000000 :
    print(-1)
else :
    print(ans)

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

if 0 in x :
    print(0)
else :
    ans = 1
    con = True
    for i in range(0, n):
        ans *= x[i]
        if ans > 1000000000000000000:
            print(-1)
            con = False
            break
    if con : 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):


#include <string>
#include <algorithm>

using namespace std;

int main(){
    double sr;
    long long int lr;
    cin >> lr >> sr;

    cout << (long long int)(double(lr%1000) * sr)+(lr/1000)*((long long int)(sr*1000)) << endl;
}


a = int(input())
li = list(map(int,input().split()))
total = 1
i = 1
for i in range(a):
    total = total*li[i]
    if total > 1000000000000000000:
        total = -1
        break
for i in range(a):
    if li[i] == 0:
        total = 0

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())
A = list(map(int, input().split()))

ans = 1
for Ai in A:
    ans *= Ai
print(ans if ans < 10 ** 18 else -1)


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

if 0 in A:
    ans = 0
else:
    ans = 1
    for Ai in A:
        ans *= Ai
        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):
import psyco
psyco.full()

n = int(input())
values = input().split()
mult = 1

for i in range(len(values)):
  mult *= int(values[i])
  if mult > 10**18:
    mult = -1
    break
    
print(mult)


n = int(input())
values = list(map(int, input().split()))
if 0 in values:
  print(0)
  return

mult = 1
for i in values:
  mult *= i
  if mult > 1000000000000000000:
    print(-1)
    return

print(mult)

n = int(input())
values = input().split()

mult = 1
for i in range(len(values)):
  mult *= int(values[i])
  
if mult >= 10**18:
  print(-1)
else:
  print(mult)

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


def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

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

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

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(reverse=True)
ans = 1
lim = 18
now = 0
for a in A:
    ans *= a
    now += len(str(a))-1
    if now >= 18:
        print(-1)
        exit()
print(ans)

n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[-1] == 0:
    print(0)
    exit()

ans = A[0]
lim = 10**18
for a in A[1:]:
    ans *= a
    if ans > lim:
        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 numpy as np

_ = input()
nums = np.array(list(map(int, input().split())))

x = np.prod(nums)
print(x if x < 10**18 else -1)

_ = input()
nums = list(map(int, input().split()))
ans = 1
 
for num in nums:
    if num==0 or ans <= 10 ** 18:
        ans *= num
    else:
        pass
 
print(ans if ans <= 10 ** 18 else -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):
n = int(input())
a = list(map(int, input().split()))

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans >= inf:
            print(-1)
            exit()

print(ans)


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

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans > inf:
            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):
str_n = input()
str_an = input()

n = int(str_n)
an = [int(ai) for ai in str_an.split()]

ans = 1
for ai in an:
  ans *= ai

if ans > 1e8:
  ans = -1
  
print(ans)


def main():
  N = int(input())
  A = [int(ai) for ai in input().split()]
  
  if 0 in A:
    print(0)
    return
  
  ans = 1
  for ai in A:
    ans *= ai
    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):
n=input()
ans=1
flag=0
for i in n:
  x=input()
  ans*=x
  if(ans>(10**18)):
    flag=1
    break

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

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

import math
 
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
  print("0")
  exit()
ans=1
for i in range(n):
  ans *= arr[i]
  if math.log10(ans) >= 18 and ans!=1000000000000000000:
    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 numpy as np

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

#A =np.array(A)

ans = A.prod()

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

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

import functools
import operator

ans = functools.reduce(operator.mul, A)

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

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

ans = 1
for i in range(N):
    ans = ans * A[i]
    if 10**18 <= ans:
        ans= -1
        break
    else:
        pass
print(ans)

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

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

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

import functools
import operator

ans = functools.reduce(operator.mul, A)

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

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

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted