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):
a,b=map(int,input().split())
ans=a*b
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(ans)

import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,'int64')
ans=np.prod(list)
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(np.prod(list))

import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,int)

p=math.log10(list)
p=p.sum()
if p>=18:
  print(-1)
else:
  print(np.prod(list))

import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,int)
ans=np.prod(list)
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(np.prod(list))


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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)


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):
from operator import mul
from functools import reduce
n = int(input())

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

ans = 1 * reduce(mul, alis)
 
if ans < 10**18:
  print(ans)
else:
  print(-1)


n = int(input())

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

ans = 1

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

n = int(input())

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

ans = 1

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


n = int(input())

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

ans = 1

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

print(-1)


n = int(input())

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

ans = 1

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

print(ans)


n = int(input())

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

ans = 1

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

print(ans)


n = int(input())

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

ans = 1

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

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

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
n = int(input())
A = list(map(int,input().split()))
ans = A[0]
MOD = 10**6
cnt = 0
for i in range(1,n):
    ans = ans * A[i]
    tmp = ans // MOD
    if tmp != 0:
        ans = ans % MOD
        cnt += tmp
    if cnt >= 3:
        ans = -1
print(ans)

n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = A[0]
INF = 1000000000000000000
for i in range(1,n):
    l,r = len(str(ans)),len(str(A[i]))
    if l+r > 18:
        ans = -1
        break
    else:
        ans = ans * A[i]
print(ans)


n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = A[0]
INF = 1000000000000000000
for i in range(1,n):
    l,r = len(str(ans)),len(str(A[i]))
    if l+r > 21:
        ans = -1
        break
    else:
        ans = ans * A[i]
        if ans > INF:
            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 = map(int, input().split())
if 0 in A:
    print(0)
    exit(0)
mul = 1
for a in A:
    if mul * a > 10 ** 18:
        print(-1)
        exit(0)
    mul *= a
print(mul)


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


Verdicts: Wrong Answer

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

Submission attempts (in order):
from sys import stdin
MAX = 10^18

def main():
    line_count = 0

    for line in stdin:
        line_count += 1
        factors_str = line.split()
        if line_count == 2:
            break

    factors = [int(factor) for factor in factors_str]
    
    if 0 in factors:
        print(0)
        return

    product = 1
    for factor in factors:
        product *= factor
        if product > MAX:
            print(-1)
            return

    print(product)

main()

from sys import stdin
MAX = 10**18

def main():
    line_count = 0

    for line in stdin:
        line_count += 1
        factors_str = line.split()
        if line_count == 2:
            break

    factors = [int(factor) for factor in factors_str]
    
    if 0 in factors:
        print(0)
        return

    product = 1
    for factor in factors:
        product *= factor
        if product > MAX:
            print(-1)
            return

    print(product)

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()))
     
    limit = 1000000000000000000
     
    result = 1
    for i in A:
      if result >= limit:
        result = -1
        break
      result = result * i
     
    print(result)

limit = 1E18

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

result = 1
for n in A:
  result *= n

if result >= limit:
  print("-1")
else:
  print(result)

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

limit = 1000000000000000000

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

print(result)

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

limit = 1000000000000000000

result = 1
if 0 not in A:
  for i in A:
    result = result * i
    if result > limit:
      result = -1
      break
else:
  result = 0

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):
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 18:45:47 2020

@author: kawati
"""

N = int(input())

MAX = 10**18
ans = 1
a = list(map(int, input().split())) 

for x in a:
    ans *= x
    if ans > MAX:
        print(-1)

# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 18:45:47 2020

@author: kawati
"""

N = int(input())

MAX = 10**18
ans = 1
a = list(map(int, input().split())) 

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


for x in a:
    ans *= x
    if ans > MAX:
        print(-1)
        exit(0)
        
        #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):
n=int(input())
A = list(map(int, input().split()))
result=1
limit=10**18
flg0=0
for i in range(n):
  if A[i] == 0:
    flg0=1
    print('0')
for i in range(n):
  if flg0 == 1:
    break
  result *= A[i]
  if result > limit:
    print('-1')
    flg=1
    break
if flg != 1 and flg0 != 1:
  print(result)

n=int(input())
A = list(map(int, input().split()))
result=1
limit=10**18
flg0=0
flg=0
for i in range(n):
  if A[i] == 0:
    flg0=1
    print('0')
for i in range(n):
  if flg0 == 1:
    break
  result *= A[i]
  if result > limit:
    print('-1')
    flg=1
    break
if flg != 1 and flg0 != 1:
  print(result)

Verdicts: Runtime Error

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

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

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

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

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

        else:
            ans=D
        

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

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

a = list(int(i) for i in input().split(" "))

prod = 1

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


print(prod)


n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

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


print(prod)


Verdicts: Runtime Error

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

Submission attempts (in order):
inp = input()
inp = input()
 
def mp(nums):
  n = 1
  limit= 10 ** 10
  for num in nums:
    n *=num
    if num > limit:
      print(-1)
      return
  print(num)
  return
 
mp([int(x) for x in inp.split(" ")])

inp=input()
nums = [int(x) for x in inp.split(" ")]

def mp(nums):
  n = 1
  for num in nums:
    n *=num
  return n

limit= mp([10]*18)
num = mp(nums)

if n>limit:
  print(-1)
else:
  print(num)

inp = input()
inp = input()
 
def mp(nums):
  n = 1
  for num in nums:
    n *=num
  	if num > limit:
  		print(-1)
  		return
  print(num)
  return
 
limit= 10 ** 10
num = mp([int(x) for x in inp.split(" ")])
 


inp = input()
inp = input()
 
def mp(nums):
  n = 1
  limit= 10 ** 10
  for num in nums:
    n *=num
  	if num > limit:
  		print(-1)
  		return
  print(num)
  return
 
mp([int(x) for x in inp.split(" ")])
 

inp = input()
inp = input()

limit= 10 ** 18

def mp(nums):
  n = 1
  for num in nums:
    n *=num
    if num > limit:
      print(-1)
      return
  print(num)
  return
 
mp([int(x) for x in inp.split(" ")])

inp = input()
inp = input()
 
def mp(nums):
  n = 1
  limit= 10 ** 10
  for num in nums:
    n *=num
  	if num > limit:
  	  print(-1)
  	  return
  print(num)
  return
 
mp([int(x) for x in inp.split(" ")])

inp = input()
inp = input()
 
def mp(nums):
  if 0 in nums:
    print(0)
    return
  n = 1
  limit = 10**18
  for num in nums:
    n *=num
    if n > limit:
      print(-1)
      return
  print(n)
 
mp([int(x) for x in inp.split(" ")])

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
 
A.sort()
rslt = a[0]

for a in A[1:]:
  result *= a
  if rslt > 10**18:
    print(-1)
    exit()
print(rslt)

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

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

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
N = int(input())
arr = np.array(list(map(int,input().split())))
s = arr.prod()
if s > 10**8:
  print(-1)
else:
  print(s)

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

Verdicts: Wrong Answer

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

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

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

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


n = int(input());
ans = 1;
zero = false
for i in map(int, input().split()):
    ans *= i
    if i==0:
        zero = true
print(ans if ans>=0 else -1);


n = int(input());
list = list(map(int,input().split()))
zero = False
for i in list:
    if i==0:
        zero = True
        break
if zero:
    print(0)
else:
    ans = 1
    for i in list:
        ans *= i
        if ans>10**18:
            ans = -1
            break
    print(ans)


Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
n=int(input())
ans=1
l=sorted(list(map(int,input().split())))
if l[0]==0:
    print(0)
else:
    for i in range(n):
        ans*=l[i]
        if ans>100000000000000000:
            ans=-1
            break
    print(ans)

n=int(input())
ans=1
l=sorted(list(map(int,input().split())))
if l[0]==0:
    print(0)
else:
    for i in range(n):
        ans*=l[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):
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    li_A = list(map(int, input().split()))

    ans = li_A[0]

    for i in range(1,N):
        if (ans * li_A[i]) < 1000000000000000000:
            ans = ans * li_A[i]

        else:
            ans = -1

    print(ans)

# coding=utf-8
import sys

if __name__ == '__main__':
    N = int(input())
    li_A = list(map(int, input().split()))

    ans = li_A[0]

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

    for i in range(1, N):
        if ans * li_A[i] > 1000000000000000000:
            print('-1')
            sys.exit()
        else:
            ans *= li_A[i]

    print(ans)



Verdicts: Wrong Answer

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

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

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

Verdicts: Wrong Answer

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

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

LIMIT = pow(10, 18)
total = 1

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

for a in A_list:
    total = total * a
    if total > LIMIT:
        print('-1')
        exit()
print(total)

N = input()
A_list = [int(e) for e in input().split()]

LIMIT = pow(10, 18)
total = 1

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

for a in A_list:
    total = total * a
    if total > LIMIT:
        print('-1')
        exit()
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):
a = list(map(int, input().split()))

s = 1
for x in a:
  s *= x
if s > 1000000000000000000:
  print(-1)
else:
  print(s)

import sys

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

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

s = 1
for x in a:
  s *= x
  if s > 1000000000000000000:
    break
if s > 1000000000000000000:
  print(-1)
else:
  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 = map(int,input().split())
ans = 1
for i in n:
    ans *= i
if ans > 10**18 :
    ans = -1
print(ans)

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

n = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
    print(0)
    quit()
ans = 1
for i in a:
    ans *= i
    #print(i)
    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):
import numpy as np 
inf = 10**18
n = int(input())
A = list(map(int,input().split()))
S = np.prod(A)
if 0 in A:
	print(0)
    break
if S > inf:
	print("-1")
	break
print(S)

import numpy as np 
inf = 10**18
n = int(input())
A = list(map(int,input().split()))
S = np.prod(A)
if A > inf;
	print("-1")
  else:
    print(S)

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

Verdicts: Runtime Error

Runtime Error

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

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

ans = 1

for i in a:
  ans = i * ans

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

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

print(ans)

n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

for i in a:
  ans = i * ans
  if ans > 10**18:
	print(over)
    exit(0)

print(ans)

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

ans = 1

for i in a:
  ans = i * ans

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

n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

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

print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
n=int(input())
line=map(int,input().split(" "))
f=0
for i in line:
  if i==0:
    print("0")
    f=1
g=1
if f==0:
  for i in line:
    g=g*i
    if g>10**18:
      print("-1")
      f=1
if f==0:
  print(g)

n=int(input())
line=input().split(" ")
f=0
print(line)
for i in line:
  if int(i)==0:
    print("0")
    f=1

g=1
if f==0:
  for i in line:
    g=g*int(i)
    if g>10**18:
      print("-1")
      f=1
      break
  if f==0:
    print(g)

n=int(input())
line=map(int,input().split(" "))
for i in line:
  if i==0:
    print("0")
    return
g=1
for i in line:
  g=g*i
  if g>10**18:
    print("-1")
    return
print(g)

n=int(input())
line=input().split(" ")
f=0

for i in line:
  if int(i)==0:
    print("0")
    f=1

g=1
if f==0:
  for i in line:
    g=g*int(i)
    if g>10**18:
      print("-1")
      f=1
      break
  if f==0:
    print(g)

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

if ans > max_limit:
  print(str(-1))
else:
  print(str(ans))

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

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

print(str(ans))

Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
prod = 1
if 0 in A:
    print(0)
else:
    for i in A:
        prod *=i
        if prod > int(1e18):
            print(-1)
            break
        print(prod)

import numpy as np
N = int(input())
A = list(map(int, input().split()))
prod = 1
if 0 in A:
    print(0)
else:
    for i in A:
        prod *=i
        if prod > int(1e18):
            print(-1)
            break
    if prod <= int(1e18):
        print(prod)

Verdicts: Wrong Answer

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

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

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


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

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


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

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

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

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


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):
import math
a,b = input().split()
n = b.find('.')
if n > 0:
  bi = int(b[:n])
  bf = int(b[n+1:])
else:
  bi,bf = int(b),0
  
ans = str(math.floor(int(a)*(bi*100+bf)))
N = ans.find('.')
if N > 0:
  ai = int(ans[:n-2])
else:
  ai = int(ans/100)
print(ai)

import math
a,b = input().split()
n = b.find('.')
if n > 0:
  bi = int(b[:n])
  bf = int(b[n+1:])
else:
  bi,bf = int(b),0
  
ans = str(math.floor(int(a)*(bi*100+bf)))
N = ans.find('.')
if N > 0:
  ai = int(ans[:n-2])
else:
  ai = int(int(ans)/100)
print(ai)

import numpy as np
N = int(input())
ans = np.prod(np.array(range(4,N)))
if ans > 10**18 or ans == 0:
  ans = -1
print(ans)

import numpy as np
N = int(input())
list = list(map(int,input().split()))
ans = np.prod(list)
if ans > 10**18 or ans == 0:
  ans = -1
if 0 in list:
  ans = 0
print(ans)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

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

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

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

j = 100000000000000000

ans = 1

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

if ans <= s:
    print(ans)
else :
    print('-1')


n = int(input())

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

j = 100000000000000000

ans = 1

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

if ans <= j:
    print(ans)
else :
    print('-1')



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

for i in range(n):
    if An[i] == 0:
        print(0)
        quit()

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

if ans > j :
    print(-1)
    
else :
    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):
N = int(input())
A = list(map(int, input().split()))

X = 1
for i in A:
    X *= i

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

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

A.sort()

X = 1
for i in range(N):
    X *= A[i]
    if X > 10**18:
        print(-1)
        break
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):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

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


if __name__ == '__main__':
    main()


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

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


if __name__ == '__main__':
    main()

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 1

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

print(res)


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 1

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

print(res)


Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    ans *= int(i) 
    if(ans > 10**18):
        ok = 0
if(tem):
    print(0)
elif(ok)
    print(ans)
else:
    print("-1")


n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    if(ok == 1):
        ans *= int(i) 
        if(ans > 10**18):
            ok = 0
if(tem):
    print(0)
elif(ok):
    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())
arr=[]
arr=list(map(int,input().split()))
mul=1
for i in range(n):
  mul*=arr[i]
  if(mul>1000000000000000000):
    print("-1")
    return
print(mul)


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


Verdicts: Runtime Error

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

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

Verdicts: Wrong Answer

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

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()
print(total_pow)

import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()

print(total_pow)


input_num = input()
input_list = input()

total_pow = 1
[total_pow*=int(num) for num in input_list.split(" ")]

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

import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)


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=np.ones(N)
a=np.ones(N)

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


a=sorted(A,reverse=True)

a_product=1
flag_1e18=False
flag_0=False

if a[N-1]==0:
  flag_0=True

for i in range(0,N,1):
  a_product=a_product*a[i]
  if a_product>1e18:
    flag_1e18=True
    break
  else:
    continue
    
if flag_1e18==True and flag_0==False:
  print(-1)
elif flag_0==True:
  print(0)
else:
  print(A_product)
  


import numpy as np

N=int(input())
A=np.ones(N)
a=np.ones(N)

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


a=sorted(A,reverse=True)

a_product=1
flag_1e18=False
flag_0=False

if a[N-1]==0:
  flag_0=True

for i in range(0,N,1):
  a_product=a_product*a[i]
  if a_product>1e18:
    flag_1e18=True
  else:
    continue
    
if flag_1e18==True and flag_0==False:
  print(-1)
elif flag_0==True:
  print(0)
else:
  print(A_product)
  


import numpy as np

N=int(input())
A=np.ones(N)
a=np.ones(N)

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


a=sorted(A,reverse=True)

a_product=1
flag_1e18=False
flag_0=False

if a[N-1]==0:
  flag_0=True

for i in range(0,N,1):
  a_product=a_product*a[i]
  if a_product>1e18:
    flag_1e18=True
    break
  else:
    continue
    
if flag_1e18==True and flag_0==False:
  print(-1)
elif flag_0==True:
  print(0)
else:
  print(a_product)
  


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

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

ans = 1

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

print(ans)

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

ans = 1
if any(j == 0 for j in A) == True:
    ans = 0
else:
  for i in A:
    ans *= i
    if ans > 10**18:
      ans = -1
      break

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

n = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
l = int(math.log10(ans)+1)
if l >= 18:
    print(-1)
else:
    print(int(ans))
    

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

Verdicts: Runtime Error

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

Submission attempts (in order):
import math

def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
flag=[0]*1000002
def seive_primes():
    flag[0]=flag[1]=1
    i=2
    while i*i<=1000000:
        if flag[i]==0:
            j=i*i
            while j<=1000000:
                flag[j]=1
                j+=i
        i+=1
def sqr(n):
    return n*n
def inp():
    ls=list(map(int,input().split()))
    return ls
ls=inp()
if math.prod(ls)>10e18:
    print(-1)
else:
    print(math.prod(ls))


import math

def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
flag=[0]*1000002
def seive_primes():
    flag[0]=flag[1]=1
    i=2
    while i*i<=1000000:
        if flag[i]==0:
            j=i*i
            while j<=1000000:
                flag[j]=1
                j+=i
        i+=1
def sqr(n):
    return n*n
def inp():
    ls=list(map(int,input().split()))
    return ls
ls=inp()
ans=1
for i in ls:
    ans*=i
    if ans>10e18:
        print(-1)
        exit(0)
print(ans)


import math

def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
flag=[0]*1000002
def seive_primes():
    flag[0]=flag[1]=1
    i=2
    while i*i<=1000000:
        if flag[i]==0:
            j=i*i
            while j<=1000000:
                flag[j]=1
                j+=i
        i+=1
def sqr(n):
    return n*n
def inp():
    ls=list(map(int,input().split()))
    return ls
N=int(input())
ls=inp()
if 0 in ls:
    print(0)
    exit(0)
ans=1
for i in ls:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit(0)
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()))
ans = 1
for a in A:
    ans *= a
    if ans * a <= 10**18:
        ans *= a
    else: ans = 10**18 + 1
        
print(ans if ans <= 10**18 else -1)

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

Verdicts: Wrong Answer

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

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

ans = 1
for l in A_list:

    ans *= l

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

def multi(L):
    ans = 1
    for l in L:
        if ans <= (10**18):
            ans *= l
            print(ans)
        else:
            ans = -1
            break
    return ans
 
N = int(input())
A_list = list(map(int, input().split()))

print(multi(A_list))

def multi(L):
  ans = 0
  for l in L:
  	if ans <=10**18:
      ans *= l
    else:
      ans = -1
      break
      
   return ans

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

print(multi(A_list))
    

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

ans = 1
if 0 in A_list:
    ans = 0
else:
    for l in A_list:

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

if ans > (10**18):
    ans = -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):
n = input()
A = [int(x) for x in input().split()]
product = 1

for a in A:
    product *= a
    if a = 0:
        break

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


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

product = 1
for a in A:
    product *= a
    if a == 0:
        break
    if product <= 10**18:
        product = -1
        break

print(product)


import sys

n = input()
A = sorted([int(x) for x in input().split()], reverse=True)

if A[-1] == 0:
    print(0)
    sys.exit()

product = 1
for a in A:
    product *= a
    if product > 10**18:
        product = -1
        break

print(product)


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

if 0 in a:
  print(0)
  break

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

else:
print(ans)


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

if 0 in a:
  print(0)
  break

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

print(ans)


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

if 0 in a:
  print(0)
  break

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

print(ans)


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

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

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

n = int(input())
a = [int(e) for e in input().split()]
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10:
            print(-1)
            break  
    else:
        print(ans)

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

sum = np.prod(np.asarray(As))
sum = sum if sum<10**18 else -1
print(sum)

N = int(input())
As = list(map(int,input().split()))
sum = 1
if 0 in As:
    print(0)
    exit()
for i in As:
    sum *=i
    if sum>10**18:
        sum = -1
        break
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):
n = int(input())
l = list(map(int,input().split()))
s = 1
f = 1
x = 1000000000000000000
for i in l:
	s *= i
	if s>x:
      print(-1)
      f = 0
      break
if f==1:
  print(s)

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

n = int(input())
l = list(map(int,input().split()))
s = 1
f = 1
x = 1000000000000000000
l.sort()
if l[0]==0:
  print(0)
elif l[0]==1 and l[-1]==1:
  print(1)
else:
  l = l[::-1]
  for i in l:
      s *= i
      if s>x:
          print(-1)
          f = 0
          break
  if f==1:
    print(s)

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


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

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

res = 1
for i in lis:
    if res > 10**18:
        print(-1)
        exit()
    else:
        res *= i
print(res if res <= 10**18 else -1)


Verdicts: Wrong Answer

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

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

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

flag = 0

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

Verdicts: Wrong Answer

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

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

ans = 1
over = 10**18

for num in nums:
    ans = ans * num
    if ans >= over:
        print(-1)
        exit()

print(ans)


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

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


ans = 1
over = 10**18

for num in nums:
    ans = ans * num

    if ans > over:
        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()))

if A.count(0) <= 1:
    print(0)
    exit(0)

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


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

if A.count(0) >= 1:
    print(0)
    exit(0)

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

n = input()
ar = map(int,input().split())
ar = list(ar)
mul=1
ar=sorted(ar)

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


Verdicts: Runtime Error

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

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum >= 10**18: print(-1);sys.exit()
print(sum)

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()
if 0 in array: print(0); sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum >= 10**18: print(-1);sys.exit()
print(sum)

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()
if 0 in array: print(0); sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum > 10**18: print(-1);sys.exit()
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):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import numpy as np
n = int(input())
a_list = np.array(list(map(int, input().split())))
y = np.argsort(a_list)
if y[0] == 0:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[y[n - 1 - i]])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)



#!/usr/bin/python3
# -*- coding: utf-8 -*-
import numpy as np
n = int(input())
a_list = np.array(list(map(int, input().split())))
y = np.argsort(a_list)
if a_list[y[0]] == 0:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[y[n - 1 - i]])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)



Verdicts: Wrong Answer

Accepted