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()))
if 0 in a:
    print(0)
for num in range(n):
    x *= a[num]
    if x > 10**18:
        print(-1)
        sys.exit()
print(x)



import numpy as np
n = int(input())
a = list(map(int,input().split()))
aProd = np.prod(a)
if (aProd >= 10**18):
    print(-1)
else:
    print(aProd)
    

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



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



import numpy as np
n = int(input())
a = list(map(int,input().split()))
if (aProd > 10**18):
    print(-1)
else:
    print(aProd)
    

import numpy as np
n = int(input())
a = list(map(int,input().split()))
aProd = np.prod(a)
if 0 in a:
    print(0)
elif aProd >= np.power(10, 18):
    print(-1)
else:
    print(aProd)
    

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
s = 1
for i in a:
  s *= i
  if s => 10 ** 8:
    s = -1
    break
if 0 in a:
  s = 0
print(s)
 

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

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

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

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

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

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

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

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


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


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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

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

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

mul=1
i=0

if 0 in p:
  print(0)
else:
  while mul<=100000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if mul>100000000000000000 or i!=n:
    print(-1)
  else:
    print(mul)

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

mul=1
i=0

if '0' in p:
  print(0)
else:
  while mul<=100000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if mul>100000000000000000 or i!=n:
    print(-1)
  else:
    print(mul)

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

mul=1

for i in p:
  mul=mul*i
  
if mul>100000000000000000:
  print(-1)
else:
  print(mul)

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

mul=1
i=0

if 0 in p:
  print(0)
else:
  while mul<=1000000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if mul>1000000000000000000 or i!=n:
    print(-1)
  else:
    print(mul)

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):
import sys
input = sys.stdin.readline

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

A.sort()

ans = 1
for a in A:
  ans = ans * a
  if ans > 1000000000000000000:
    print -1
    quit()

print(ans)


import sys
input = sys.stdin.readline

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

A.sort()

ans = 1
for a in A:
  ans = ans * a
  if ans > 1000000000000000000:
    print(-1)
    quit()

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):
limit = 1E18
n = input()
total = 0
for i in range(n):
  x = input()
  total += x
  if total > limit:
    print(-1)
    exit()
    
print(total)

limit = 1E18
n = int(input())
total = 1
# A string
line = str(input())

if line.startswith("0 ") or " 0" in line:
    print(0)
    exit()

for i in line.split():
    x = int(i)
    total *= x
    if total > limit:
        print(-1)
        exit()

print(-1 if total > limit else 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):
import numpy
N = input()
An = input().split()
AnS = numpy.prod(An)
print(AnS)


import sys
N = int(input())
An = list(map(int,input().split()))
a = 1
if 0 in An:
    print("0")
    sys.exit()
else:
    for i in range(N):
        a *= An[i]
        if a > 10**18:
            print("-1")
            sys.exit()
    if a <= 10**18:
        print(a)
        sys.exit()


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())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	ans*=p[i]
	n-=1
	if(p[i]==0):
		break
	if(ans>k):
		break
	i+=1		
if(ans>k):
		print(-1)
else:
		print(ans)
		


n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
while(n>i):
	ans*=p[i]
	n-=1
	if(p[i]==0):
		break
	if(ans>1000000000000000000):
		break
	i+=1		
if(ans>1000000000000000000):
		print(-1)
else:
		print(ans)
		


#include <bits/stdc++.h>
using namespace std; 
typedef long long int  ll;
#pragma GCC optimize("O3")
#define pb push_back

int32_t main()  {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n ;
	cin >> n ;
	ll ans = 1;
	ll k = 1000000000000000000;
	int fl =0;
	while ( n--)
	{
		ll in ;
		cin >> in;
		ans=ans*in;
		if(ans>k) {
			fl=1;}
		if(in==0){
			ans=0;
		}
		if(ans!=0)	
		if((k/ans)>in) {
			fl=1;
		}	
	}
	if(	fl==1 and ans!=0)
	cout<<-1<<endl;
	else
	cout << ans;
}


n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		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()))
ans=1
keta=1
a.sort()
for i in a:
    keta+=(len(str(i))-1)
    #print(keta)
    if(i==0):
        ans=0
        break
    if(keta>18):
        ans=-1
        break
    ans=ans*i
    if(ans>1000000000000000000):
        ans=-1
        break

print(ans)

n=int(input())
a=list(map(int,input().split()))
ans=1
keta=1
a.sort()
for i in a:
    
    #print(keta)
    if(i==0):
        ans=0
        break
    
    ans=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(x) for x in input().split())
number =1

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

print(number)

N = int(input())
a = (int(x) for x in input().split())
number = 1
for i in a:
    number *= i
    
if number>10*18:
    number = -1

if N <2 or N >1*5:
    number = -1
print(number)

N = int(input())
a = (int(x) for x in input().split())
number = 1
for i in a:
    number *= i
    
if number>10^18:
    number = -1


print(number)

N = int(input())
a = (int(x) for x in input().split())
number = 1
for i in a:
    number *= i
    
if number>10^18:
    number = -1



print(number)

N = int(input())
a = (int(x) for x in input().split())
number = 1
for i in a:
    number *= i
    
if number>10*18:
    number = -1

if N <2 or N >10*5:
    number = -1
print(number)

N = int(input())
a = (int(x) for x in input().split())
number = 1
for i in a:
    number *= i
    
if number>10*18:
    number = -1
    
print(number)

from sys import exit
n = int(input())
a = [int(i) for i in input().split()]
number =1

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

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

print(number)

Verdicts: 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):
if min(As)==0:
    num=0
else:
    num=1
    for i in range(N):
        num *= As[i]
        if num>10**18:
            print("breakに突入")
            num=-1
            break

print(num)

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

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

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

for i in range(N):
    num *= As[i]
    
if num>10^18:
    num=-1

print(num)

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

if min(As)==0:
    num=0
else:
    num=1
    for i in range(N):
        num *= As[i]
        if num>10**18:
            num=-1
            break

print(num)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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

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


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


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

for a in A:
  X*=a
if X>=1000000000000000000:
  print(-1)
else:
  print(X)

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

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

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

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

Verdicts: Runtime Error

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

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

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

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

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

print(a)

p = np.prod(a, axis=0)

print(p)

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


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

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

def ans(a):
    if 0 in a:
        return 0
    n = 1
    for i in a:
        n *= i
        if n > 10**18
            return -1
    return n

print(ans(a))

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

def ans(a):
    if 0 in a:
        return 0
    n = 1
    for i in a:
        n *= i
        if n > 10**18:
            return -1
    return n

print(ans(a))

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

# multiple = 1

#     multiple *= A[i]



# if multiple <= 10 ** 18 :
#     print(multiple)
# else:
#     print(-1)


if 0 in A:
    print(0)
    return

output = 1
for a in A:
    output *= a
    
    if output > 10 ** 18:
        print(-1)
        return

print(output)



N = int(input()) 

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

# multiple = 1

#     multiple *= A[i]



# if multiple <= 10 ** 18 :
#     print(multiple)
# else:
#     print(-1)

def main():
    if 0 in A:
        print(0)
        return

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

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

    print(output)

main()


Verdicts: Runtime Error

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

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))
X=1
if 0 in A:
  print(0)
  break

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


N=int(input())
A=list(map(int,input().split()))
X=1
for idx in range(N):
  X=X*A[idx]

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


N=int(input())
A=list(map(int,input().split()))
X=1
if 0 in A:
  print(0)
  return

for idx in range(N):
  X=X*A[idx]
  if X >1*10**18:
    print(-1)
    return

print(X)

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

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


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):
def b169(n, alist):

    ans = 1
    for i in alist:
        ans *= i

    return ans if ans < 10**18 else -1

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

def b169(n, alist):

    ans = 1
    for i in alist:
        ans *= i

    return ans if ans < 10**18 else -1

def main():
    n = int(input())
    alist = list(int(input()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

def b169(n, alist):

    ans = 1
    for i in alist:
        if i == 0:
            return 0

    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    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())
l=list(map(int,input().split()))
out=1
for x in l:
    out=out*x
print(out) if out<10**18 else print(-1)

n=int(input())
l=list(map(int,input().split()))
out=1
for x in l:
    out*=x
print(out) if out<10**18 else print(-1)

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

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):
#A
n = int(input())
a = list(map(int, input().split()))
ans = 1
b = 0
for i in a:
    ans *= i
    if ans > 10 ** 18:
        b = -1
if ans == 0:
    b = 0
if b != -1:
    print(-1)
else:
    print(ans)


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

Verdicts: Wrong Answer

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

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

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

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

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

def dfs(l, r):

    if l==r:
        return A[l]
    mid = (l+r)//2
    ans = 1
    ans = ans * dfs(l, mid)
    ans = ans * dfs(mid+1, r)
    return ans

ans = dfs(0, len(A)-1)

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

Verdicts: Wrong Answer

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

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

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

print(ans)


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

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

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

for i in range(len(a)):
    if a[i] == 0:
        print(0)
        exit()

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

print(ans)


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

for i in range(len(a)):
    if a[i] == 0:
        print(0)
        exit()

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

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

N = int(input())
A = np.array([int(a) for a in input().split()])

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

import sys

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

if "0" in A:
    print(0)

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

        if ans>10**18:
            print(-1)
            sys.exit()
            
    if ans<=10**18:
        print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
A=input()
list1=input().split()
A=int(A)
 
Ans=1
for i in range(0,A):
    Ans= Ans*int(list1[i])
 
if 10**18<=Ans:
    print(-1)
else:   
    print(Ans)

A=input()
list1=input().split()
A=int(A)
Ans=1
#---------------------------

if "0" in list1:
    print("0")
    
else:
    for i in range(0,A):
        Ans=Ans*int(list1[i])    
        if Ans >10**18:
            print(-1)
            break
        else:
            print(Ans)

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

Ans=1
for i in range(0,A):
    Ans*= Ans*int(list1[i])

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

A=input()
list1=input().split()
A=int(A)
Ans=1
#---------------------------

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

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

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

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


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

ans=1

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

    if ans>10**18:
        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):
N = input().split()

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

sortlist = list.sorted()

answer = 1

for a in sortlist:
    answer = answer*a
    if answer == 0:
        break
    if answer > 10^18:
        answer = -1
        break
    else:
        continue


N = input().split()

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

sortlist = list.sorted()

answer = 1

for a in sortlist:
    answer = answer*a
    if answer == 0:
        break
    if answer > 10^18:
        answer = -1
        break
    else:
        continue

print(answer)

N = input().split()

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

list.sort()

answer = 1

for a in list:
    answer = answer*a
    if answer == 0:
        break
    if answer > 10**18:
        answer = -1
        break
    else:
        continue

print(answer)

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

res = 1
for a in a_list:
    res *= a
if res // (10 ** 18) == 1:
    res = -1
print(res)

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

res = 1
if 0 in a_list:
    print(0)
    exit()

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
input()
l = map(int, input().split())
r = 1
if 0 in l:
    print(0)
else:
    for i in l:
        r *= i
        if r > 1e18:
            break
    print(-1 if r > 1e18 else r)

input()
l = list(map(int, input().split()))
if 0 in l:
    print(0)
else:
    r = 1
    for i in l:
        r *= i
        if r > 1e18:
            break
    print(-1 if r > 1e18 else r)

Verdicts: Wrong Answer

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

Submission attempts (in order):
str_list_size = input()
str_num = input()
num_list = str_num.split()
list_size = int(str_list_size)

answer = 1
for i in range(0, list_size):
    answer *=int(num_list[i])
    if answer >= 10**18:
        answer = -1
        break

print(answer)

str_num = input()
num_list = str_num.split()

answer = 1
for i in range(1, int(num_list[0])+1):
    answer *=int(num_list[i])
    if answer >= 10**18:
        answer = -1
        break

print(answer)

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

    print(answer)

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

    print(answer)

main()

str_num = input()
num_list = str_num.split()

answer = 1
for number in num_list:
    answer *=int(number)
    if answer >= 10**18:
        answer = -1
        break

print(answer)

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

    print(answer)

main()

Verdicts: Wrong Answer

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):
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int lli;
#define MAX 100005

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n;
	cin>>n;
	lli mask = 1;
	lli temp;
	bool flag = false;
	bool fzero = false;
	for(lli i = 0; i<n; i++){
		cin>>temp;
		mask *= temp;
		if(mask < 0 || mask > 1000000000000000000){
			flag = true;
		}
		if(temp == 0)
			fzero = true;
	}
	if(fzero){
		cout<<0<<endl;
		return 1;
	}
	if(flag){
		cout<<"-1"<<endl;
		return 1;
	}
	cout<<mask<<endl;
}


# number of elements 
n = int(input()) 
  
# Below line read inputs from user using map() function  
a = list(map(int,input().strip().split()))[:n] 
  
mask = 1;
flag = 0;
for num in a:
    if(num == 0):
            flag = 1
mask = 1;
flagex  = 0;
if(flag == 1):
    print(0)
else:
    for num in a:
        mask *= num;
        if(mask > 1000000000000000000):
            flagex = -1;
            break;
    if(flagex == -1):
        print(-1);
    else:
        print(mask);
            

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):
_ = input()
l = list(map(int, input().split(" ")))

ans = functools.reduce(lambda x, y : x* y, l, 1)

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


import sys
_ = input()
l = list(map(int, input().split(" ")))

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

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

print(ans)

Verdicts: Runtime Error

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

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

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

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

import numpy as np
N=int(input())
A=list(map(int,input().split()))
A.sort()
if A[0]==0:
    print('0')
elif np.prod(A)<10**18:
    print(np.prod(A))
else: print('-1')

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

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

flag = 0
if data.count(0) > 0:
  print(0)
else
	a = data[0]
	for i in range(1,n):
  		a = a*data[i]
        if a > 10**18:
          flag = 1
          break

	if flag == 1:
  		print('-1')
	else
		print(a)

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
j = 0
    
while i<n:
  while j < n:
    if data[j]==0:
    	  a = 0
    	  break
    j +=1
  break
  a = a*data[i]
  i += 1
 
if a > 10**18:
  a = -1
 
print(a)

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1

if a > 10^18 -1 :
  a = -1
 
print(a)

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
    
while i<n:
  while j < n:
  	if data[j]==0:
    	a = 0
    	break
    j +=1  
  a = a*data[i]
  i += 1

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

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

a = 1
while i<n:
  a = a*data[i]
  i += 1
  if a > 10^18:
    a = -1

print(a)

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1
  if a > 10^18:
    a = -1
    break
 
print(a)

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1
  if a > 10^18:
    a = -1
    break
 
print(a)

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1

if a > 10^18:
  a = -1
 
print(a)

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

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

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):
#include<bits/stdc++.h>
using namespace std;

#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	int n; cin >> n;
    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(All(v));
    if(v[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = v[n-1];
    for(int i = 0; i < n-1; i++){
        ans *= v[i];
        if(ans > (ll)1e18){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans < 0){
        cout << -1 << endl;
    }
    else cout << ans << endl;
    system("pause");
}


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

for i in range(N):
  sum = sum * A[i]

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

print(sum)

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

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

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

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
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)-1):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)

N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      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()))

ans = 1
for i in A:
  ans = ans * i
  if ans > 10 ** 18:
	  print("-1")
      break
  else:
    continue
else:
  print(ans)

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

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


Verdicts: Runtime Error

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

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

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

import sys

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

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

count = 1

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

for i in A:
    count *= i

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

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

count = 1

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

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

print(count)

Verdicts: Runtime Error

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

Submission attempts (in order):
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
input = stdin.readline
N = int(input())
A = list(map(int,input().split()))
np_A = np.array(A)
ans = np_A[0]

2
for i in range(1, N, 1):
    ans = ans*np_A[i]
    if ans > 10**18:
        flag = False
        break


if flag == False:
    print(-1)

else:
    print(ans)


# -*- coding: utf-8 -*-
from sys import stdin
from decimal import *
import numpy as np
input = stdin.readline
N = int(input())
A = list(map(Decimal,input().split()))
np_A = np.array(A)
ans = np_A[0]

zero_flag = False
if 0 in A:
    zero_flag = True

flag = True

for i in range(1, N, 1):
    ans = Decimal(ans)*Decimal(np_A[i])
    #print(ans)
    if ans > 10**18:
        flag = False
        break


if zero_flag == True:
    print(0)


else:
    if flag == False:
        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):
from sys import stdin
input = sys.stdin

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

from sys import stdin
input = stdin

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


from sys import stdin
input = stdin.readline

n = int(input())
aa = list(map(int, input().split()))
if 0 in aa:
  print(0)
  exit()
ans = 1
for a in aa:
  ans *= a
  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):
import numpy as np
N = int(input())
A = [int(a) for a in input().split()]

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

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

ans = np.prod(A, dtype=np.uint64)
if ans >= 10**18:
    print(-1)
else:
    print(ans)

import numpy as np
N = int(input())
A = [int(a) for a in input().split()]

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

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

import numpy as np
N = int(input())
A = [int(a) for a in input().split()]
ans = A[0]

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

print(ans)

import numpy as np
N = int(input())
A = [int(a) for a in input().split()]
ans = A[0]

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

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

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

for x in a:
  i *= x
  if i > 1000000000000000000:
    break
  elif i == 0:
    break

if i > 1000000000000000000:
  i = -1
print(i)

open Batteries
let n = read_int ()
let a = read_line () 
let a2 = a |> String.split_on_char ' ' |> List.map int_of_string
let rec loop lst r=
  match lst with
  | [] -> r
  | first :: rest ->
    if List.mem 0 a2 then 0 else
    if first <> 1 && 1000000000000000000 / 2 <= r then -1 else
    loop rest (r*first)

let l = loop a2 1
let _ = l |> Printf.printf "%d\n"

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

for x in a:
  i *= x
  if i > 10 ** 18:
    break


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

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

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

if(ans > 10^18):
    ans = -1

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


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


Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)

import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
lim = 10**18
ans = np.prod(a)
 
if ans >= lim:
  ans = -1
    
print(ans)

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

lim = 10**9
lim_1 = 10**18
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim_1:
  ans = -1
elif ans < 0:
  ans = -1
  
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(input().split())
for i in range(N):
    A[i] = int(A[i])
sum = 1

for i in range(N):
    if sum <= 10**18:
        sum = sum * A[i]
    else:
        break:

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

N = int(input())
A = list(input().split())
flag = 0
for i in range(N):
    A[i] = int(A[i])
    if A[i] == 0:
        flag = -1
sum = 1

for i in range(N):
    if sum <= 10**18:
        sum = sum * A[i]
    else:
        break


if sum <= 10**18:
    print(sum)
else:
    if flag == -1:
        print(0)
    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):
import math

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

n = 1
for i in A_list:
  n = n * i

if n == 0:
  print(n)
elif math.log10(n) >= 18:
  print(-1)
else:
  print(n)
  

import math
from operator import mul
from functools import reduce

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

n = reduce(mul, A_list)

if n == 0:
  print(n)
elif math.log10(n) >= 18:
  print(-1)
else:
  print(n)

import math

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

n = 1
for i in A_list:
  n = n * i
  if math.log10(n) >= 18:
    print(-1)
    break
else:
  print(n)

import math

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

n = 1
for i in A_list:
  if 0 in A_list:
    print(0)
    break
  n = n * i
  if math.log10(n) >= 18:
    print(-1)
    break
else:
  print(n)

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

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

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

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

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


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

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


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

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


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
a=list(map(int,input().split()))
result=1
if 0 in a:
    print(0)
else:
    for i in a:
        result*=i
        if result>10**18:
            print(-1)
            break
    if result<=10**18:
        print(result)

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

n=int(input())
a=list(map(int,input().split()))
result=1
if 0 in a:
    print(0)
else:
    for i in a:
        result*=i
        if result>10**18:
            print(-1)
            break
    if result<=10**18:
        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):
#
import sys
import math
import numpy as np
import itertools

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



#
import sys
import math
import numpy as np
import itertools

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

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




Verdicts: Wrong Answer

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

Submission attempts (in order):
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= abs(i)
  if 10 ** 18 < total:
    print('-1')
    quit()

print(sign * total) 

# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= abs(i)

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

# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= i
  if 10 ** 18 < total:
    print('-1')
    quit()

print(total) 

Verdicts: Runtime Error

Runtime Error

Accepted