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

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from operator import mul
from functools import reduce

import numpy as np

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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


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


import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np

N = int(input())
A = np.array(input().split(), dtype=np.float128)

total = np.prod(A)
if total > 10 ** 18:
    print(-1)
else:
    print(total)




import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from operator import mul
from functools import reduce

import numpy as np

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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


total = A.cumprod()
score = total[-1]
# print(total)

if score > 10 ** 18:
    print(-1)
else:
    print(score)
# if total > 10 ** 18:
#     print(-1)
# else:
#     print(total)


import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

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

limit = 10 ** 18
A = sorted(A)

total = A[0]
if total == 0:
    print(total)
    exit()

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
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):
N = int(input())
A = list(map(int,input().split()))
x = 1
t = 0
for i in range(N):
  x*= A[i]
  if x>= pow(10,18):
    t = 1
    break
if t == 1:
  print(-1)
else:
  print(x)
  
  

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


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 el in A:
    prod *= el
    if prod > 1e18:
      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 el in A:
    prod *= el
    if prod > 1e18:
      print(-1)
      return
  print (prod)
  
  
main()

Verdicts: Wrong Answer

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

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

ans=1
for i in range(N):
    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: 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
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)

    if logsum >= 18:
        print('-1')
        return

    for a in As:
        prod *= a

    print(prod)

    # As = []
    
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())


import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)
        # sys.stderr.write('{}\n'.format(logsum))


    if logsum > 18:
        print('-1')
        return

    for a in As:
        prod *= a

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

    # As = []
    
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())


import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        logsum += math.log10(a)

    if logsum >= 18:
        print('-1')
        return

    for a in As:
        prod *= a

    print(prod)

    # As = []
    
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())


import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)
        # sys.stderr.write('{}\n'.format(logsum))


    if logsum > 18.2:
        print('-1')
        return

    for a in As:
        prod *= a

    if prod > 10 ** 18:
        print('-1')
        return
    print(prod)

    # As = []
    
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
flag = False
for i in a:
    ans *= i
    if (ans >= pow(10,18)):
        flag = True

if (flag):
    ans = -1
if 0 in a:
    ans = 0

print(ans)




n = int(input())
a = [int(x) for x in input().split()]
ans = 1
flag = False
zeros = False
over = pow(10,18)
for i in a:
    if flag == False:
        ans *= i
    if (ans > over):
        flag = True
    if i == 0:
        zeros = True

if (flag):
    ans = -1
if (zeros):
    ans = 0

print(ans)




Verdicts: Wrong Answer

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

Submission attempts (in order):
# your code goes here
n = int(input())
a = input().split()
res = 1
zero = 0
for e in range(n):
	if e == 0:
		zero = 1
for e in range(n):
	res *= int(a[e])
	if res > 1000000000000000000:
		break
if zero == 1:
	print(0)
elif res > 1000000000000000000:
	print(-1)
else:
	print(res)

# your code goes here
n = int(input())
a = input().split()
res = 1
zero = 0
for e in range(n):
	if int(a[e]) == 0:
		zero = 1
for e in range(n):
	res *= int(a[e])
	if res > 1000000000000000000:
		break
if zero == 1:
	print(0)
elif res > 1000000000000000000:
	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 = int(input()).split()
a.sort()
if a[0] == 0:
  print(0)
  return
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 10**18:
    print(-1)
    return
print(ans)

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


Verdicts: Runtime Error

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

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

As = 1
for i in range(N):
    As = As*A[i]
    if 1000000000000000000 < As:
        print(-1)
        break

if 1000000000000000000 < As:
    print(As)


N = int(input())
A = [i for i in map(int, input().split())]

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

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



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):
intNum = int(input())
numList = [int(x) for x in input().split()]

total = 1
judgeNum = 10 ** 18

if 0 in numList:
    total = 0
else:
    for num in numList:
        total *= num
        print("num", num)
        print("total", total)

        if total > judgeNum:
            total = -1
            break

print(total)

intNum = int(input())
numList = [int(x) for x in input().split()]

total = 1
judgeNum = 10 ** 18

if 0 in numList:
    total = 0
else:
    for num in numList:
        total *= num

        if total > judgeNum:
            total = -1
            break

print(total)

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

def cal():
  n=int(input())
  arr=list(map(int,input.split()))
  prod=1
  for i in range(0,n):
    prod*=arr[i]
    if(prod>=1000000000000000000):
      print(-1)
      return
  print(prod)
  return

cal()

def main():
  n=int(input())
  arr=list(map(int,input.split()))
  prod=1
  for i in range(0,n):
    prod*=arr[i]
    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 > 1000000000000000000:
      print(-1)
      return
    
  print(prod)
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):
import numpy as np
 
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
ans = np.prod(a)
 
if ans >= 1000000000000000000:
    print(-1)
else:
    print(ans)

import numpy as np
import sys
input = sys.stdin.readline

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

for i in a:
    ans = ans*i
    if ans >= 1000000000000000000:
        ans = -1
        exit
    elif ans == 0:
        exit

print(ans)

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

for i in a:
    ans = ans*i

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

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

for i in a:
    ans = ans*i
    if ans >= 1000000000000000000:
        ans = -1
        exit
    elif ans == 0:
        exit

print(ans)

import numpy as np
import sys
input = sys.stdin.readline
 
n = int(input())
a = list(map(int,input().split()))
ans = 1

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

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 = input().split(" ")
i = 0
s = 1
f = 0
while i < a :
    if b[i] == "0" :
        f = f + 1
    i = i + 1
while i < a :
    s = s * int(b[i])
    i = i + 1
    if s > (10 ** 18) and f == 0:
        print("-1")
        break
if (s <= (10 ** 18)) and f == 0 :
    print(s)
if f > 0 :
    print(0)

a = int(input())
b = input().split(" ")
i = 0
s = 1
f = 0
while i < a :
    if b[i] == "0" :
        print(0)
        f = f + 1
    i = i + 1
i = 0
while (i < a) and f == 0 :
    s = s * int(b[i])
    i = i + 1
    if s > (10 ** 18):
        print("-1")
        break
    if (s <= 10 ** 18) and (i == a):
        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=[int(i) for i in input().split()]
result=1
for i in range(n):
	result = result * a[i]
	if result > 100000000000000000 and a[i] != 0:
		print(-1)
		exit()
if result > 100000000000000000:
	print(-1)
else:
	print(result)


n=int(input())
a=[int(i) for i in input().split()]
result=1
for i in range(n):
	result = result * a[i]
	#if result >= 100000000000000000:
	#	print(-1)
	#	exit()
if result > 100000000000000000:
	print(-1)
else:
	print(result)

n=int(input())
a=[int(i) for i in input().split()]
result=1
if 0 in a:
	print(0)
	exit()
for i in range(n):
	result *= a[i]
	if result > 1000000000000000000 and a[i] != 0:
		print(-1)
		exit()
print(result)


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

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

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

n=int,input()
a=list(map(int,input().split()))
from operator import mul
from functools import reduce
x=reduce(mul, a)
if x>=10**18:
    print('-1')
else:
    print(x)

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

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

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

for i in x:
  if i==0:
    print(0)
    exit(0)

ans=1
for i in x:
  ans*=i
  if ans>100000000000000000:
    print(-1)
    exit(0)
print(ans)

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

for i in x:
  if i==0:
    print(0)
    exit(0)

ans=1
for i in x:
  ans*=i
  if ans>1000000000000000000:
    print(-1)
    exit(0)
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys

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

if a.index(0):
    print(0)
    sys.exit()

hg = 10 ** 18
ans = 1
for i in a:
    ans *= i
    if ans > hg:
        print(-1)
        sys.exit()

print(ans)

import sys

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

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

hg = 10 ** 18
ans = 1
for i in a:
    ans *= i
    if ans > hg:
        print(-1)
        sys.exit()

print(ans)

Verdicts: Runtime Error

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

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

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

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

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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

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

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

a = int(input())
b = [int(i) for i in input().split()]
last = 1
if 0 not in b:
  for i in b:
      last*=i
      if last > 10**18:
      	last = -1
        break

else:
  last = 0
    
print(last)

a = int(input())
b = [int(i) for i in input().split()]
last = 1
for j,i in enumerate(b):
    last*=i
    if last > 10**18 and 0 not in b[j:]:
    	last = -1
        break


    
print(last)

a = int(input())
b = [int(i) for i in input().split()]
last = 1
for j,i in enumerate(b):
    last*=i
    if last > 10**18 and 0 not in b[j::]:
    	last = -1
        break


    
print(last)

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

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

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

import numpy as np
n,*a=map(int,open(0).read().split())
s=1
a=np.array(a)
if any(a==0):
  print(0)
  exit()
for i in list(a):
  if i>=10**18/s:
    print(-1)
    exit()
  s=s*i
print(s)

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

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


Verdicts: Runtime Error

Wrong Answer

Runtime Error

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

Submission attempts (in order):
def main():
  n = int(input())
  k = input()
  m = k.split()
  
  if "0" in m == True:
    print(0)
    return
  
  ans = 1
  for hui in m:
    ans *= int(hui)
    
    if ans >= 10**18:
        ans = -1
        break
        
  print(ans)
  
main()

def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**18:
            answer = -1
            break

    print(answer)

main()


Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  ans *= i
  if ans > 1e18:
  	print(-1)
    return
  
if ans > 1e18:
  print(-1)
else:
  print(ans)


def solve():
  ans = 1
  if 0 in A:
    return 0
  for i in A:
    ans *= i
    if ans > 1e18:
      return -1
  return ans


N = int(input())
A = list(map(int, input().split()))
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):
N=int(input())
A=[*map(int,input().split())]
a=1
while A:
  a*=A.pop()
  if a >= 10**18:
    print(-1)
    break
else:
  print(a)

from decimal import Decimal
N=int(input())
A=[*map(str,input().split())]
a=Decimal('1')
while A:
  a=a*Decimal(A.pop())
  if a > Decimal('10'**'18'):
    print(-1)
    break
else:
  print(a)

N=int(input())
A=[*map(int,input().split())]
a=1
if 0 in A:
  a=0
else:
  while A:
    a*=A.pop()
    if a>10**18:
      a=-1
      break
print(a)

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):
import sys
def main():
    N = int(input())
    A_list = [int(_) for _ in input().split()]
    ans = 1
    
    for i in range(N):
        ans *= A_list[i]
        if ans>10**18:
            ans = -1
        break
    out = ans

    print(out)

main()

import sys
def main():
    N = int(input())
    A_list = [int(_) for _ in input().split()]
    ans = 1
    
    if 0 in A_list:
        out = 0
        print(out)
        sys.exit()
    
    for i in range(N):
        ans = ans * A_list[i]
        
        if ans>1000000000000000000:
            ans = -1
            break
    out = ans
    print(out)

main()

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = [int(s) for s in input().split()]
ans = 1
for i in a:
    ans *= i
    if ans <= (10 ** 18):
        ans = -1
        break
print(ans)

def main():
    n = int(input())
    a = [int(s) for s in input().split()]
    ans = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        ans *= i
        print(ans)
        if ans > (10 ** 18):
            ans = -1
            break
    print(ans)
main()

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

sum = 1

if any(a == 0 for a in As):
	sum = 0
else:
	for a in As:
		sum*=a
		if sum > 1000000000000000000:
			sum = -1
			break
print(sum)


#A,B=map(int,input().split())






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

sum = 1

if any(b == 0 for b in As):
	sum = 0
else:
	for a in As:
		sum*=a
		if sum > 1000000000000000000:
			sum = -1
			break
print(sum)


#A,B=map(int,input().split())






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())
str_list = input().split()

result = 1

for i in range(n):
  if(int(str_list[i]) == 0):
    result = 0
    break
  result = result * int(str_list[i])

if(result >= 1000000000000000000):
  print('-1')
else:
  print(result)
   


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

result = 1

for i in range(n):
  result = result + str_list(i)
  
t = 1
for j in range(18)
  t = t * 10
if(result > t):
  print('-1')
else:
  print(result)
   

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

result = 1

for i in range(n):
  result = result * int(str_list[i])
  
t = 1
for j in range(18)
  t = t * 10
if(result > t):
  print('-1')
else:
  print(result)
   


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

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  return

for i in range(n):
  result = result * list[i]
  if(result >= 1000000000000000000):
    print('-1')
    return

print(result)
  


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

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  return

for i in range(n):
  result = result * list[i]
  if(result >= 1000000000000000000):
    print('-1')
    return

print(result)
  


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

result = 1

for i in range(n):
  result = result * int(str_list(i))
  
t = 1
for j in range(18)
  t = t * 10
if(result > t):
  print('-1')
else:
  print(result)
   


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

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  exit()

for i in range(n):
  result = result * list[i]
  if(result >= 1000000000000000000):
    print('-1')
    exit()

print(result)
  


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

result = 1

if('0' in str_list):
  print('0')
  exit()

for i in range(n):
  result = result * int(str_list[i])
  if(result >= 1000000000000000000):
    print('-1')
    exit()

print(result)
  


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

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  exit()

for i in range(n):
  result = result * list[i]
  if(result > 1000000000000000000):
    print('-1')
    exit()

print(result)
  


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

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

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

reg = A[0]
flg=True
if 0 in A:
    print(0)
    flg=False
    reg=0
for i in range(1, N):
    reg *= a
    if reg>10**18:
        print(-1)
        flg=False
        break
if flg:
    print(reg)

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

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

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

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

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

#!/usr/bin/env python

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

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

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

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

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


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)


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, input().split())
A.sort()

ans = 1

if A[0] == 0:
  print(0)
else:
  for a in A:
    ans *= a
    if ans > 1000000000000000000:
      print(-1)
      break
  print(ans)


_, *A = map(int, input().split())
ans = 1

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


_, *A = map(int, open(0).read().split())
ans = 1

if 0 in A:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
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):
def calc(num_list) -> int:
    result = 1
    max = 10**18

    if 0 in num_list:
        return 0
        
    for num in num_list:
        result *= num
        if result > max:
            return -1
    return result

n = int(input())
num_list = map(int, input().split())

print(str(calc(num_list)))

n = int(input())
num_list = map(int, input().split())

max = pow(10, 18)
result = 1
for num in num_list:
  if num == 0:
    print(0)
    break
    else:
      result = result * num
      if result > max:
        print(-1)
        break 
        print(result)

def calc(num_list) -> int:
    result = 1
    max = 10**18

    if 0 in num_list:
        return 0

    for num in num_list:
        result *= num
        if result > max:
            return -1
    return result

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

print(str(calc(num_list)))

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):
dontt_use = input()
n = map(int,list(input().split()))
total = 1
for number in n:
    total = total * number

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

dontt_use = input()
n = map(int,list(input().split()))
total = 1
for number in n:
    total = total * number
    if total > 10**18:
        print('-1')
        return
print(total)

dontt_use = input()
str_list = list(input().split())
n = map(int,str_list)

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        print(total)
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

dontt_use = input()
str_list = list(input().split())
n = map(int,str_list)

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

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

cumul = 1
for i in range(N):
    cumul *= nums[i]

if cumul > 10 ** 18: print(-1)
elif:print(cumul)


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

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

if cumul < 10**18: print(cumul)

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

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

if cumul < 10 ** 18: print(cumul)


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

cumul = 1
if 0 in nums: print(0)
else:
	for i in range(N):
    	cumul *= nums[i]
		if cumul > 10 ** 18:
      		print(-1)
      		break
	if cumul <= 10 ** 18: print(cumul)


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

cumul = 1
if 0 in nums:
    print(0)
else:
    for i in range(N):
        cumul *= nums[i]
        if cumul > 10 ** 18:
            print(-1)
            break
    if cumul <= 10 ** 18: print(cumul)


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

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


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


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

        a=a*List[i]
        if a>10**18:
            print('-1')
            break   
    print(a)
    if not a>10**18:
        print(a)

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

else:
    for i in List:
        a=a*i
        if a>10**18:
            print('-1')
            break
if not a>10**18 and not 0 in List:
    print(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):
import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  a = 10 ** 18
  if 0 in s:
    print(0)
    sys.exit()
  for k in range(K):
    prod = prod * s[k]
    if prod >= a:
      print(-1)
      sys.exit()
  
  print(prod)

if __name__ == '__main__':
  main()

import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  if 0 in s:
    print(0)
    sys.exit()
  for k in range(K):
    prod = prod * s[k]
  if prod >= 10 ** 18:
    print(-1)
  else:
    print(prod)

if __name__ == '__main__':
  main()

import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  a = 10 ** 18
  if 0 in s:
    print(0)
    sys.exit()
  for k in range(K):
    prod = prod * s[k]
    if prod > a:
      print(-1)
      sys.exit()
  
  print(prod)

if __name__ == '__main__':
  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):
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    n = int(read.input())
    a = list(map(int,read().split()))
    ans = 1
    flag = True
    for num in a:
      ans *= num
      if ans > 10**18:
        flag = False
        break
    print(ans if flag else -1)
 
if __name__ == "__main__":
    main()

import sys
#import cython
 
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    n = int(read())
    a = list(map(int,read().split()))
    ans = 1
    flag = True
    iszero = any(num == 0 for num in a)
    if iszero: print(0)
    else:
        for num in a:
          ans *= num
          if ans > 10**18:
            flag = False
            break
        print(ans if flag else -1)
 
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):
def solve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=1
    a.sort()
    
    for i in a:
        ans*=i
        if(ans>=1000000000000000000):
            print("-1")
            return
    
    print(ans)

solve()

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

solve()

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

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

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

def main(n,a):
    if(a.count(0)!=0):
        return 0
        
    res=a[0]
    for i in range(1,n):
        res*=a[i]
        if res>INFTY:
            return -1
    return res

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

INFTY=10**18

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

def main(n,a):
    if(a.count(0)!=0):
        return 0
        
    res=a[0]
    for i in range(1,n):
        res*=a[i]
        if res>INFTY:
            return -1
    return res

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,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()))
sum_=1
for i in range(N):
    while sum_ < 10**18:
        sum_ *= a[i]
        if sum_ > 10**18:
            sum_ =-1
        break
        if sum_ = 0:
        break
print(sum_)

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

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

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

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

print(ans)


n = int(input())

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

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

ans = 1
for i in range(n):
    ans = ans * a[i]

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

n = int(input())

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

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

ans = 1
for i in range(n):
    ans = ans * a[i]

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

Verdicts: Runtime Error

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):
ans = 1
ok = True
_n = int(input())
a = list(map(int,input().split()))
for i in a:
    ans *= i

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

ans = 1
ok1 = True
_n = int(input())
a = list(map(int,input().split()))
ok2 = False
if 0 in a:
    ok2 = True

for i in a:
    ans *= i
    if ans > 1e18:
        ok1 = False
        break

if ok2:
    print(0)
elif ok1:
    print(ans)
else :
    print(-1)
    


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())
ans = 1
flg = True

if '0' in list(input().split()):
    print(0)
else:
    for a in input().split():
        _a = int(a)
        ans *= _a
        if ans > 10 ** 18:
            print(-1)
            flg = False
            break

    if flg:
        print(ans)


n = int(input())
ans = 1
flg = True
input_a = list(input().split())

if '0' in input_a:
    print(0)
else:
    for a in input_a:
        _a = int(a)
        ans *= _a
        if ans > 10 ** 18:
            print(-1)
            flg = False
            break

    if flg:
        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())
num = list(map(int,input().split(" ")))
 
s = num[0]
 
for i in range(1,n):
  s = s * num[i]
    
if len(str(s)) > 17:
  print(-1)
else:
  print(s)

n = int(input())
num = list(map(int,input().split(" ")))

sum = num[0]

for i range(1,n):
  if len(str(sum)) > 16:
    sum = -1
    break
  sum = sum * num[i] 

print(sum)

n = int(input())
num = list(map(int,input().split(" ")))
 
s = num[0]
 
for i range(1,n):
  s = s * num[i] 
 
print(s)

n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)

if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if len(str(s)) > 18:
      s=-1
      break
  print(s)

n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)

if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
  if len(str(s)) > 18:
    print(-1)
  else:
    print(s)

n = int(input())
num = list(map(int,input().split(" ")))

s = num[0]

for i range(1,n):
  if len(str(s)) > 16:
    s = -1
    break
  s = s * num[i] 

print(s)

n = int(input())
num = list(map(int,input().split(" ")))
 
s = num[0]
 
for i in range(1,n):
  s = s * num[i]
    
if len(str(s)) > 18:
  print(-1)
else:
  print(s)

n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)
z= 10 **18
if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if s > z:
      s=-1
      break
  print(s)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

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

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

n = int(input())
A = list(map(int,input().split()))
answer = 1
flag = 1
zero = 0
for i in range(n):
    answer *= A[i]
    if answer > pow(10,18):
        flag = 0
        break
if 0 in A:
    print(0)
elif flag ==0:
    print('-1')
else:
    print(answer)

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 input2():
	return map(int,input().split())
  
n=int(input())
A=input_array()
MAX=10**18
ans=A[0]

for i in range(1,len(A)):
	ans*=A[i]
	if ans==0:
		break
	elif ans>MAX:
		ans=-1
		break
	else:
		pass

print(ans)


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


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


def input_array():
	return list(map(int,input().split()))

n=int(input())
A=input_array()
MAX=10**18
ans=1
for i in A:
	ans*=i
if ans >= MAX:
	print(-1)
else:
	print(ans)


def input_array():
	return list(map(int,input().split()))

def swap(a,b):
	tmp=a
	a=b
	b=tmp
	return a,b

n=int(input())
A=input_array()
MAX=10**18
A=sorted(A)
ans=A[0]
for i in range(1,len(A)):
	ans*=A[i]
	if ans==0:
		break
	elif ans>MAX:
		ans=-1
		break
	else:
		pass

print(ans)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted