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

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
i = 0
ans = 0
if 0 in a:
    print(0)
else:
    while ans<10**10 and i<len(a):
        ans*=a[i]
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)


i = 0
ans = 1
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    while ans<10**18 and i<len(a):
        ans*=a[i]
        i+=1
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)

Verdicts: Time Limit Exceeded

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


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


Verdicts: Wrong Answer

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

Submission attempts (in order):

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

R=1
if 0 in A:
    print("0")
else:
    for i in range(0, N):
        R=R*A[i]
        if R>1000000000000000000:
            print("-1")
            exit()
        else:
            print(R)



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

R=1
if 0 in A:
    print("0")
else:
    for i in range(0, N):
        R=R*A[i]
        if R>1000000000000000000:
            print("-1")
            exit()
        else:
            print(R)



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

R=1
if 0 in A:
    print("0")
else:
    for i in range(0, N):
        R=R*A[i]
        if R>1000000000000000000:
            print("-1")
            exit()
        
    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):
import numpy as np
N = int(input())

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

import numpy as np
N = int(input())
A = list(map(int, input().split()))
se = 1
c = True
for n in range(N):
  se *= A[n]
  if se >  10**18:
    c = False
    break
for n in range(N):
  if A[n] == 0:
    se = 0
    c = True
if c:
  print(se)
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):
n=int(input())
l=list(map(int,input().split()))
a=l[0]
for i in range(1,n):
    a*=l[i]
if a>10**8:
    print(-1)
else:
    print(a)

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

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

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

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

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

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

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

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

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

Verdicts: Runtime Error

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

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

result = 1

for num in nums:
    result *= num

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

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

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

result = 1
for num in nums:
    result *= num

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

print(result)



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

result = 1

for num in nums:
    result *= num

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

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

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

result = 1
for num in nums:
    result *= num

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

print(result)



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

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

result = 1
for num in nums:
    result *= num

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



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

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

result = 1
for num in nums:
    result *= num

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

print(result)



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
if 0 in n:
    print(0)
for n in numbers:
    mlt *= n
    if mlt > 1000000000000000000:
        mlt = -1
        break
print(mlt)


N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
if 0 in numbers:
    print(0)
else:
    for n in numbers:
        mlt *= n
        if mlt > 1000000000000000000:
            mlt = -1
            break
    print(mlt)


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

n = int(input())
list_a=list(map(int, input().split()))  
list_a.sort(reverse=True)
# list_a = sort(list_a)
result = 1
for i in list_a:
    result = result * i
    if len(str(result)) > 18:
        print(-1)
        break

if len(str(result)) <+ 18:
    print(result)


import functools
import operator

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

for i in list_a:
    result = functools.reduce(operator.mul, list_a)

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

import functools
import operator

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

result = functools.reduce(operator.mul, list_a)

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

import functools
import operator

n = int(input())
list_a=list(map(int, input().split()))  
result = 1
for i in list_a:
    result = result * i
    if len(str(result)) > 18:
        print(-1)
        break

if len(str(result)) <+ 18:
    print(result)


import functools
import operator

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

result = functools.reduce(operator.mul, list_a)

if len(str(result)) < 18:
    print(result)
else :
    print(-1)	
    

n = int(input())
list_a=list(map(int, input().split()))  
resu = 1
for i in list_a:
    resu = resu * i

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

import functools
import operator

n = int(input())
list_a=list(map(int, input().split()))  
list_a.sort(reverse=True)
# list_a = sort(list_a)
result = 1
for i in list_a:
    result = result * i
    if len(str(result)) > 18:
        print(-1)
        break

if len(str(result)) <= 18:
    print(result)



n = int(input())
list_a=list(map(int, input().split()))  
list_a.sort(reverse=True)
# list_a = sort(list_a)
result = 1
if list_a[-1] == 0 :
    print(0)
else:
    for i in list_a:
        result = result * i
        if result > 1000000000000000000:
            print(-1)
            break

    if result <= 1000000000000000000:
        print(result)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

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

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

total = 1
for i in range(N):
    total = total*A_list[i]
    if total // 10**18 >= 1:
        print(-1)
        exit()

print(total)


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

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

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

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

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

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

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

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


ans=1
for elem in A:
    ans*=elem
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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

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

a.sort()

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

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

a.sort()

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = [int(i) for i in input().split()]
x = 1
f = 0
a.sort()
for i in range(n):
    print(a[i])
    x = x*a[i]
    if x == 0:
        print(0)
        f = 1
        break
    elif x > 1000000000000000000:
        print(-1)
        f = 1
        break
if f == 0:
    print(x)

n = int(input())
a = [int(i) for i in input().split()]
x = 1
f = 0
a.sort()
for i in range(n):
    #print(a[i])
    x = x*a[i]
    if x == 0:
        print(0)
        f = 1
        break
    elif x > 1000000000000000000:
        print(-1)
        f = 1
        break
if f == 0:
    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):
スコード
m
1
import numpy
2
n = int(input())
3
m = list(map(int,input().split()))
4
s = 1
5
a = 0
6
if 0 in m:
7
  print(0)
8
  a =1
9
else:
10
  for i in range(n):
11
    s=s*m[i-1]
12
    if s>10**18:
13
      print(-1)
14
      a = 1
15
      break
16
if a == 0:
17
  print(s)
※ 512 KiB まで

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

Verdicts: Runtime Error

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

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

ls=[int(s) for s in input().split(" ")]

num=1

for i in ls:
  num*=i
  
if num <= 10**1:
  print(num)
else:
  print(-1)

n=int(input())
ls=[int(s) for s in input().split(" ")]

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

  print(num)

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

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

n = int(input())
ans = 1

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

n = int(input())
ans = 1

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
k=input()
a=list(map(int,input().split()))
p=1
count=0
while(count<len(a)):
    p*=a[count]
    count+=1
    if(p>pow(10,18)):
        print("-1")
        break
if(p<pow(10,18)):
    print(p)

k=input()
a=list(map(int,input().split()))
p=1
count=0
if(len(a)==0):
    print("0")
while(count<len(a)):
    p*=a[count]
    count+=1
    if(p>pow(10,18)):
        print("-1")
        break
if(p<pow(10,18)and len(a)>0):
    print(p)

k=input()
a=list(map(int,input().split()))
p=1
count=0
if(len(a)==0):
    print("0")
elif 0 in a:
    print("0")
else:
    while(count<len(a)):
        p*=a[count]
        count+=1
        if(p>pow(10,18)):
            print("-1")
            break
    if(p<=pow(10,18)and len(a)>0):
        print(p)

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

k = 0
ans = 1
while k < n:
    ans = ans * A[k]
    k += 1
    if ans >= 10**18:
        ans = -1
        break

print(ans)

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

k = 0
ans = 1
while k < n:
    ans = ans * A[k]
    k = +1
    if ans > 10**18:
        ans = 0
        break

print(ans)

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

k = 0
ans = 1
for k in range(n):
    ans *= A[k]
    k += 1
    if ans > 10**18:
        ans = -1
        break

print(ans)

Verdicts: Wrong Answer

Wrong Answer

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

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

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

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

total = 1
for i in range(n):
  x = int(input())
  total = total*x

if total <= 1000000000000000000:
  print(total)
else:
  print(-1)

n = int(input())
 
List = [int(i) for i in input().split()]
lst = sorted(List, reverse=True)
if lst[-1] == 0:
  print(0)
  exit()
total = 1
for i in lst:
  total = total*i
  if total > 1000000000000000000:
    print(-1)
    exit()
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 = input()

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

total = 1

if a in 0:
	total = 0
else:
	for i in a:
		total *= i

if total > 10**18:
	total = -1

print(total)


n = int(input())

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

total = 1

for i in a:
	total *= i

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


n = int(input())
 
a = set(map(int, input().split()))
 
total = 1
 
for i in a:
	total *= i
 
if total > 10**18:
	total = -1
 
print(int(total))

n = int(input())

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

total = 1

for i in a:
	total *= i

if total > 10**18:
	total = -1

print(total)


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

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a
    if 10 ** 18 < total:
        total = -1
        break
print(total)

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):
def main():
  n = int(input())
  data = list(map(int, input().split()))
  if 0 in data:
    print(0)
    return
  
  c = 1
  for d in data:
    c *= d
    if c >= 10 ** 18:
      print(-1)
      return
  
  print(c)


if __name__ == "__main__":
  main()


def main():
  n = int(input())
  data = list(map(int, input().split()))
  if 0 in data:
    print(0)
    return
  
  c = 1
  for d in data:
    c *= d
  
  if c >= 10 ** 18:
    print(-1)
  else:
    print(c)


if __name__ == "__main__":
  main()


def main():
  n = int(input())
  data = list(map(int, input().split()))
  if 0 in data:
    print(0)
    return
  
  c = 1
  for d in data:
    c *= d
    if c > 10 ** 18:
      print(-1)
      return
  
  print(c)


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):
N = int(input())
A = list(map(int, input().split()))
def main():
    maxi = 10*18
    mult = 1
    for a in A:
        mult *= a
        if mult > maxi:
            print(-1)
            return 
    print(mult)

main()

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

main()

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

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):
#!/usr/bin/env python3
from decimal import Decimal
a, b = input().split()
a = Decimal(int(a))
b = Decimal(b)
print(int(a * b))

#!/usr/bin/env python3
import numpy as np
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = np.prod(A)
elif ans > i:
    print(-1)
else:
    print(int(ans))

#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
b = 1
i = 10**18
A = sorted(A)
for a in A:
  if b > i:
    break
  b *= a
print(-1 if b > i else b)

Verdicts: Runtime Error

Runtime Error

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

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


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

ans = 1

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

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

print(ans)

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

a = sorted(a)

ans = 1

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

print(ans)

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

a = sorted(a)

ans = 1

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

print(ans)


Verdicts: Wrong Answer

Wrong Answer

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

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

if 0 in A:
    print(0)
    return 

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        return 

print(Π)

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

Π = 0
for _ in A:
    Π *= _
    if(Π > 10e+18):
        print(-1)
        exit(0)

print(Π)


import sys

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

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

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        sys.exit(0)

print(Π)


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


def main():
  p = 1
  for v in range(t):
    p *= n[v]
    if (p >= 10 **18):
      print("-1")
      return
  print(p)

main()


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


def main():
  p = 1
  for v in t:
    p *= n[v]
    if (p >= 10 **18):
      print("-1")
      return
  print(p)

main()


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


def main():
  if 0 in n:
    print(0)
    return
  p = 1
  for v in range(t):
    p *= n[v]
    if (p > 10 **18):
      print("-1")
      return
  print(p)

main()


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

n = input()
lista = list(map(int,input().split()))
r = 1

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

n = input()
lista = list(map(int,input().split()))
r = 1

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

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):
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
m = 10**18

res = reduce(lambda x,y: x*y, a)
res = 1
for n in a:
    res *= a
    if res > m:
        print(-1)
        exit()
    
print(res)

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

print(res)

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

print(res)

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



N = int(input())

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



sum=reduce(operator.mul, a, 1)



if sum < 1000000000000000000:
    print(sum)
else:
    print('-1')

import numpy as np

N=int(input())


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



if np.prod(a)>=0:
    sum=np.prod(a)
else:
    print('-1')

if sum<1000000000000000000:
    print(sum)
else:
    print('-1')


import numpy as np

N=int(input())


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



if np.prod(a)>=0:
    sum=np.prod(a)
else:
    sum=-1

if sum<1000000000000000000:
    print(sum)
else:
    print('-1')


import numpy as np

N = int(input())

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

sum = a[0]

if a.count(0)>=0:
    print('0')
    exit()


for i in range(1, N):
    sum = sum * a[i]
    if sum > pow(10, 18):
        print('-1')
        break



import numpy as np

N = int(input())

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

sum = a[0]


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

for i in range(1, N):
    sum = sum * a[i]
    if sum > 10**18:
        print('-1')
        exit()

print(sum)




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 = int(input())
li = input().split(" ")
x = 1
if 0 in li:
    print(0)
else:
    for i in li:
        x = x * i
        if x > 10**18:
            print(-1)
            exit()
    print(x)


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


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

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

x = 1
for i in list:
    x = x * int(i)
    if x > 10**18:
        print(-1)
        exit()
print(x)


Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
import numpy as np
_ = input()
A = list(map(int, input().split()))
b = np.prod(A)
b = b if b < 10 ** 18 else -1
print(b)

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

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

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


_ = input()
A = list(map(int, input().split()))
b = np.prod(A)
b = b if b < 10 ** 18 else -1
print(b)

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

ans = 1
for a in A:
    ans *= a

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


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):

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

ans = 1
max = 1000000000000000000
for i in range(len(N)):
  ans = ans * N[i]

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

import sys
input = sys.stdin.readline

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

ans = 1
max = 10**18
if 0 in N:
  print(0)
else:
  for i in range(len(N)):
    ans = ans * N[i]
    if ans > max:
      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 numpy as np

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

ans = int(0)
if(A[0] == 0):
    ans = 0
else:
    ans = np.prod(A)

if ans >= 1e18:
    print('-1')
else:
    print(f'{ans}')

import numpy as np
import math

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

ans = np.prod(A)

if ans >= pow(10,18):
    print('-1')
else:
    print(ans)

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

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

A.sort()

ans = 1
for i in A:
    ans *= i
    if ans > MAX:
        ans = -1
        break

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

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

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

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

n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    result = an*result
    if result > target:
      result = -1
      break
 
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())
nums = input().split()
mul = int(nums[0])
if str(0) in nums:
    mul = 0
else:
    for i in nums[1:]:
        mul *= int(i)
        if len(str(mul)) >= 19:
            mul = -1
            break
print(mul)

N = int(input())
nums = input().split()
mul = int(nums[0])
for i in nums[1:]:
    if str(0) in mul:
        mul = 0
        break
    if len(str(mul)) > 19:
        mul = -1
        break
    mul *= int(i)
print(mul)

N = int(input())
nums = input().split()
mul = int(nums[0])
if str(0) in nums:
    mul = 0
else:
    for i in nums[1:]:
        mul *= int(i)
        if len(str(mul)) >= 19:
            print(mul)
            mul = -1
            break
print(mul)

N = int(input())
nums = input().split()
mul = int(nums[0])
if str(0) in nums:
    mul = 0
else:
    for i in nums[1:]:
        mul *= int(i)
        if len(str(mul)) >= 19 and str(mul) != "1000000000000000000":
            mul = -1
            break
print(mul)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
prod = 1
def main()
    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()))
for i in range(N):
    B = B * A[i]
    if B > 10 ** 18:
        print(-1)
        break
if B <= 10 ** 18:
    print(B)

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

Verdicts: 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):
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, A: "List[int]"):
    A = np.asarray(A)


    ans = np.prod(A)

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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    A.sort()
    ans =1
    for a in A:
        ans = ans * a

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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

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):
if 0 in A:
  print(0)
  exit()

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

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

N = int(input())
A = list(map(int,input().split()))
lim = 10**18

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

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

if ans > lim:
  print(-1)
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):
import sys
N = input()
a = list(map(int, input().split()))

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

b=1
for i in range(0,N):
    b *= a[i]
    if b > 1000000000000000000:
        print(-1)
        sys.exit

print(b)

import sys
N = int(input())
a = list(map(int, input().split()))

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

b=1
for i in range(0,N):
    b *= a[i]
    if b > 1000000000000000000:
        print(-1)
        sys.exit()

print(b)

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

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


Verdicts: Wrong Answer

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

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

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

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

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

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


print(c)



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


print(c)


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
lim = 10 ** 18
l = 0

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

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans >= lim:
    l = 1
    break
  else:
    pass

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

N = int(input())
ans = 1

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

for n in range(N):
  ans = ans * A[n]

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

N = int(input())
ans = 1
lim = 10 ** 18
l = 0

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

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans > lim:
    l = 1
    break
  else:
    pass

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

Verdicts: Wrong Answer

Wrong Answer

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

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

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

    else:
        print(ans)


n = int(input())
num_list = list(map(int,input().split()))
ans = 1
if 0 in num_list:
    print(0)
    
else:
    for i in num_list:
        ans *= i
        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):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans = ans*i
        if ans > 1000000000000000000 and i !== 0:
            print(-1)
            ans = -1
            break
    if ans != -1:
        print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans = ans*i
    if i == 0:
        print(0)
        ans = -1
        break
    elif ans > 1000000000000000000 and i !== 0:
        print(-1)
        ans = -1
        break
if ans != -1:
    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)
        ans = -1
        break
if ans != -1
    print(ans)


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


Verdicts: Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
    

N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
    

N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
print(sum)

Verdicts: Wrong Answer

Wrong Answer

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

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

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

Ans = 1
for i in range(0,len(A)):
    Ans *= A[i]
    if Ans > 10**9:
        print(-1)
        exit()
    else:
        continue
print(Ans)

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

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

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

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

Ans = 1
for i in range(0,len(A)):
    Ans *= A[i]
    if Ans > 10**18:
        print(-1)
        exit()
    else:
        continue
print(Ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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

Submission attempts (in order):
n = int(input())
num_list=list(map(int,input().split()))
ans = 1
for i in n:
  ans = ans*num_list[i]
if ans <1000000000000000000:
  print(ans)
else:
  print("-1")

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

n,m = map(int,input().split())
ans = n *m
if ans <1000000000000000000:
  print(ans)
else:
  print("-1")

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

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):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
if t > 1e18:
    print(-1)
else:
    print(np.prod(A))


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


#import numpy as np
N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
t = A[0]
for i in range(1,N):
    t *= A[i]
    if int(t) > 1e18:
        for j in range(i,N):
            if A[j] == 0:
                t = 0
        break
print(t)
if int(t) <= 1e18:
    print(int(t))
else:
    print(-1)


#import numpy as np
N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
t = A[0]
for i in range(N):
    t *= A[i]
    if int(t) > 1e18:
        for j in range(i,N):
            if A[j] == 0:
                t = 0
        break
if int(t) <= 1e18:
    print(int(t))
else:
    print(-1)


#import numpy as np
N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
t = A[0]
for i in range(1,N):
    t *= A[i]
    if int(t) > 1e18:
        for j in range(i,N):
            if A[j] == 0:
                t = 0
        break
if int(t) <= 1e18:
    print(int(t))
else:
    print(-1)


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

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


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
for x in a:
  ans *= x
  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):
str = int(input())
str2 = input()

str3 = str2.split(" ")

res = 1
for i in range(0, str):
    res *= int(str3[i])

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

str = int(input())
str2 = input()

str3 = str2.split(" ")

res = 1
for i in range(0, str):
    res *= int(str3[i])
    if res >= 10 ** 18:
        res = -1
        break

    
print(res)

str = int(input())
str2 = input()
str3 = str2.split(" ")
res = 1
isZero = False


for i in range(0, str):
    if 0 == int(str3[i]):
        isZero = True
        res = 0

if not isZero:
    for i in range(0, str):
        res *= int(str3[i])
        if res > 10 ** 18:
            res = -1
            break

    
print(res)

Verdicts: Wrong Answer

Wrong Answer

Accepted