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):
def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.index(0)==1:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()


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

    print(cal)
    return


main()


def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.count(0)>=0:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>10**18:
            print("-1")
            return

    print(cal)
    return


main()


def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.index(0):
        print(0)
        return
        
    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()


N=int(input())
a=list(map(int,input().split()))
cal=1

for i in range(N):
    cal*=a[i]

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

else :
    print(cal)


def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.count(0)>=1:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()


def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.count(0)>=1:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>10**18:
            print("-1")
            return

    print(cal)
    return


main()


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import numpy as np
n = int(input())
lista = [int(e) for e in input().split()]
lista = np.array(lista,dtype='float128')
ans = np.prod(lista)

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

print(ans)

import numpy as np
n = int(input())
lista = [int(e) for e in input().split()]
lista = np.array(lista)
ans = np.cumprod(lista)

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

print(ans)

n = int(input())
lista = [int(e) for e in input().split()]

if 0 in lista:
    ans = 0
else:
    ans = 1
    for i in lista:
        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):
N=int(input())
A = list(map(int, input().split()))
S=1
if 0 in A:
  S=0

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

import numpy as np
N=int(input())
A=np.array[input()]
S=1

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


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

for i in range(N):
  S=S*A[i]
  if A[i]==0:
    S=0

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

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


main()

import numpy as np
N=int(input())
A = list(map(int, input().split()))
A=np.array(A)
S=A.prod()

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



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


main()

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


main()



import numpy as np
N=int(input())
A = list(map(int, input().split()))
A=np.array(A)
S=A.prod()

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

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

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

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

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


main()



Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    a=1
    for i in A:
        a=a*i
        if a>1000000000000000000:
            print(-1)
        else:
            print(a)

        

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

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

        

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

ans=1

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

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

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

while True:
	N = int(input())
	if N>=2 and N<=10**5:break


num = list(map(int, input().split()))
print(num)
ans = reduce(mul,num)
if ans > 10**18:
	print(-1)
else:
	print(ans)


def main():
    n = int(input())
    a = list(map(int,input().split()))
    if 0 in a: 
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
if __name__ =="__main__":
    main()

Verdicts: Wrong Answer

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

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

    if 0 in A:
        print(0)
        return

prod = 1
for a in A:
    prod *= a
    if prod > 10000000000000000000:
        print(-1)
        return

print(prod)

main()


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

    if 0 in A:
        print(0)
        return

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

print(prod)

main()


#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vals(N);
  for (int i = 0; i < N;i++){
    cin >> vals.at(i);
  }
  int prod = std::accumulate(vals.begin(), vals.end(), 1, [](int init, int v) { return init * v; });
  if (prod > pow(10, 18)){
    cout << "-1" << endl;
  }
  else cout << prod << endl;
}


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

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

main ()

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

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

    print(prod)

main(A)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

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

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

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

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

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

temp = 1

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

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

temp = 1

if 0 in a:
    print(0)

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

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

temp = 1

if 0 in a:
    print(0)

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

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):
# B
n = int(input())

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

  

  

maxa = 10 **18

ans = 1
if min(a) == 0:
  ans = 0

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


# B
n = int(input())

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

  

  

maxa = 10 **18

ans = 1
if min(a) == 0:
  ans = 0

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

if 1*(10**18)+1<=total:
  print("-1")
else:
  print(total)

N=int(input())
total=1
A=list(map(int,input().split()))
flag=True
high=1*(10**18)+1
if A.count(0)>=1:
  total=0
else:
  for i in range(N):
    total*=A[i]
    if high<=total:
      flag=False
      break

if not flag:
  print("-1")
else:
  print(total)

Verdicts: Runtime Error

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

Submission attempts (in order):
// #include <bits/stdc++.h>

#include <map>
#include <cmath>

#include <iomanip>
#include <algorithm>

#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;




#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)

#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))


#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);

#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VLL A(n);
  INPUT(A);
  if (MIN(A) == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  LL s = 1;
  REP(int, i, n)
  {
    s *= A[i];
    if (s > 1000000000000000000)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << s << endl;

  return 0;
}


n = int(input())
A = list(map(int, input().split()))
s = 1
if min(A) == 0:
  print(0)
  exit(0)
for i in range(n):
  s *= A[i]
  if s > 1e18:
    print(-1)
    exit(0)
print(s)


Verdicts: Runtime Error

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

Submission attempts (in order):
N=int(input())
Alist=list(map(int,input().split()))
multi=Alist[0]
ibreak=0
if(Alist.count(0)>=0):
    print(0)
else:
    for i in range (N-1):
        multi*=Alist[i+1]
        if(multi>1e18):
            print(-1)
            ibreak=1
            break;
    if(ibreak==0):
        print(multi)

N=int(input())
Alist=list(map(int,input().split()))
multi=Alist[0]
ibreak=0
if(Alist.count(0)>0):
    print(0)
else:
    for i in range (N-1):
        multi*=Alist[i+1]
        if(multi>1e18):
            print(-1)
            ibreak=1
            break;
    if(ibreak==0):
        print(multi)

Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( i == 0):
        print(0)
        return
    product = product * int(i)

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

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

N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( int(i) == 0):
        print(0)
        return
    product = product * int(i)

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

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

main ()


Verdicts: Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
n,*a=map(int,open(0).read().split())
if min(a)==0:
    print(0)
else:
    s=1
    for i in range(len(a)):
       s=s*a[i]
       if s>10*18:
           print(-1)
           break
    else:
        print(s)

n,*a=map(int,open(0).read().split())
if min(a)==0:
    print(0)
else:
    s=1
    for i in range(len(a)):
       s=s*a[i]
       if s>10**18:
           print(-1)
           break
    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())
sum = 1
for num in input().split():
    sum *= int(num)
    if sum == 0:
        print(0)
        exit()
if len(str(sum)) > 19:
    print(-1)
    exit()
elif len(str(sum)) == 19 and str(sum).count("1") == 1 and str(sum).count("0") == 18:
    print(-1)
    exit()
print(sum)

N = int(input())
sum = 1
for num in input().split():
    sum *= int(num)
    if sum == 0:
        print(0)
        exit()
if len(str(sum)) > 19:
    print(-1)
    exit()
elif len(str(sum)) == 19 and sum == 10**18:
    print(-1)
    exit()
print(sum)

N = int(input())
sum = 1
keta = 0

numbers = input().split()
if not ("0" in numbers):
    for num in numbers:
        keta += len(num) - 1
        if keta > 19:
            print(-1)
            exit()
        sum *= int(num)
        if len(str(sum)) > 19:
            print(-1)
            exit()
        
    if len(str(sum)) == 19:
        if str(sum).count("1") == 1 and str(sum).count("0") == 18:
            pass
        else:
            print(-1)
            exit()
else:
    print(0)
    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):
import sys
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
	print(0)
	sys.exit(0)
ans = 1
for i in arr:
	ans *= i
	print(ans)
	if ans > 10**18:
		ans = -1
		break
print(ans)

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

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

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

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

N=int(input())
L=list(map(int,input().split()))
A=1
for i in range(N):
  A=A*L[i]
  if 10**18&lt;A:
    print(-1)
    exit()
print(A)

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

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

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

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

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

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

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

ans = 1
keta = 0
for x in A:
  ans *= x
  keta += len(str(x))
  if keta > 18:
    print(-1)
    exit()

print(ans)


N = int(input())

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

ans = 1
keta = 0
if 0 in A:
  print(0)
  exit()

for x in A:
  ans *= x
  keta += len(str(x))
  if keta > 18:
    print(-1)
    exit()

print(ans)


N = int(input())

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

ans = 1
keta = 0
if 0 in A:
  print(0)
  exit()

for x in A:
  ans *= x
  keta += len(str(x))
  if ans > 1000000000000000000:
    print(-1)
    exit()

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 = list(map(int, input().split()))
if np.prod(A)>=10**18:
    print(-1)
else:
    print(np.prod(A))

N = int(input())
A = list(map(int, input().split()))
A.sort()
a = 1
for i in A:
    a *= i
    if a > 10**18:
        a = -1
        break
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):
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author apurba_debnath
 */

#include <bits/stdc++.h>


#define DEBUG(x) cout << '>' << #x << ':' << x << endl

using namespace std;

class BMultiplication2 {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        ll a[101010];
        ll zero = 0;
        for (int i = 0; i < n; ++i) {
            in >> a[i];
            if (a[i] == 0)
                zero++;
        }
        if (zero)
            out << 0;
        else {
            ll p = 1;
            for (int i = 0; i < n; ++i) {
                if (a[i] <= 1e18 / p)
                    p *= a[i];
                else {
                    out << "-1";
                    return;
                }
            }
            out << p;
        }
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    BMultiplication2 solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);

    return 0;
}


def func():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for item in A:
        prod *= item
        if prod > 1e18:
            print(-1)
            return
    print(prod)

func()

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())
nums = list(map(int, input().split(' ')))
ans = np.prod(nums)
if ans >= 10**18:
    print(-1)
else:
    print(ans)

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

n = int(input())
ans = 1
nums = map(int, input().split(' '))
if 0 in nums:
    print(0)
    exit()
else:
    for i in nums:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
print(ans)

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

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

Verdicts: Wrong Answer

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

N = int(input())
A = list(map(int, input().split()))
res = 1
if 0 in A:
    res = 0
for a in A:
    if res > 10 ** 18 // max(1, a):
        res = -1
        break
    res *= a
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, *a = map(int, open(0).read().split())
res = 1
if 0 in a:
  print(0)
  exit()
for a in a:
  res *= a
  if res >= 1e18:
    res = -1
    break
print(res)

n, *a = map(int, open(0).read().split())
res = 1
for a in a:
  res *= a
  if res >= 1e18:
    res = -1
    break
print(res)

n, *a = map(int, open(0).read().split())
res = 1
if 0 in a:
  print(0)
  exit()
for a in a:
  res *= a
  if res > 1e18:
    res = -1
    break
print(res)


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 i in a:
    ans *= i
    if ans > 10**18:
    ans = -1
    break

print(ans)


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

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

if a.count(0) > 0:
    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):
n = int(input())
l = map(int,input().split())
total = 1
for i in l:
    total *= i

if total >= 1000000000000000000 :
    total = -1

print(total)

n = int(input())
l = map(int,input().split())
total = 1
if 0 in l:
    total = 0
else:
    for i in l:
        total *= i
        if total >= 1000000000000000000:
            total = -1
        
    
print(total)

n = int(input())
l = map(int, input().split())
total = 1

if __name__ == '__main__':
    for i in l:
        total *= i
        if total > 1000000000000000000:
            total = -1
            break

    if 0 in l :
        total = 0
    print(total)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n = input()
list = [int(x) for x in input().split(" ")]
result = 1
for i in range(len(list)):
    result = result*list[i]
    if result > 10**8:
        result = -1
        break
print(result)

n = input()
list = [int(x) for x in input().split(" ")]
result = 1
for i in range(len(list)):
    result = result*list[i]

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

n = input()
list = [int(x) for x in input().split(" ")]
result = 1
if 0 in list:
    print(0)
else:
    for i in range(len(list)):
        result = result*list[i]
        if result > 10**18:
            result = -1
            break
    print(result)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    if(0 in a==True):
        print(0)
        exit()
    ans=ans*calc[i]
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)


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


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

for calc in a:
    ans*=calc
    if(ans>10**18):
        print(-1)
        exit()
if(ans>10**18):
    print(-1)
else:
    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()))
if 0 in a:
    print(0)
    exit()
a = sorted(a, reverse=True)
res = a[0]
for ai in a[1:]:
    res *= ai
    if res > 10**18:
        print(-1)
        exit()

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
a = sorted(a, reverse=True)
res = a[0]
for ai in a[1:]:
    res *= ai
    if res > 10**18:
        print(-1)
        exit()
print(res)

Verdicts: Wrong Answer

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

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

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

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 :
    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):
31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

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


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

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

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

print(ans)


Verdicts: Runtime Error

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

Submission attempts (in order):
import operator
num = int(input())
a = list(map(int, input().split()))
result = reduce(operator.mul,a)
if result > 1000000000000000000:
    print(-1)
else:
    print(result)

ans = 1
flag = 0

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

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

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

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

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

print(ans)


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

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

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

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

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):
import numpy as np

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = np.array(a[0])
sum = arr.cumprod()
ans = sum[-1]
if ans >= 10**18:
    ans = str('-1')
print(ans)

import numpy as np

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = np.array(a[0])
sum = arr.cumprod()
ans = sum[-1]
if ans >= 10**18:
    print(-1)
else:
    print(ans)

import numpy as np

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = np.array(a[0])
log_arr = np.log10(arr)
sum = log_arr.cumsum()
ans = 10**(sum[-1])
if ans >= 10**18:
    ans = str('-1')
print(ans)

import numpy as np
import sys

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = a[0]
list.sort(arr, reverse=True)

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

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

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


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

judge=10**18
ans = 1

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

for i in A:
  ans *= i
  if ans > judge:
    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())
num_list = np.array(list(map(int, input().split())))

ans = np.prod(num_list)

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

import numpy as np
N = int(input())
num_list = np.array(list(map(int, input().split())))

ans = np.prod(num_list)

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

import numpy as np
N = int(input())
num_list = list(map(int, input().split()))

# ans = np.prod(num_list)
ans = num_list[0]
for i in range(1, N):
    if ans > 10**18:
        break
    ans *= num_list[i]


if 0  in num_list:
    print(0)
elif ans > 10**18:
    print("-1")
else:
    print(ans)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n=int(input())
x=1000000000000000000
res=1
for i in range(n):
  res=res*int(input())
if(res>x):
  print("-1")
else:
  print(res)

n=int(input())
x=1000000000000000000
res=1
for i in range(n):
  x=int(input())
  res=res*x
if(res>x):
  print("-1")
else:
  print(res)


n=int(input())
x=1000000000000000000
res=1
for i in range(n):
	res=res*int(input())
if(res>x):
	print("-1")
else:
	print(res)


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


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

ans = 1
for a in A:
    ans *= a
    if ans > 10**9 + 7:
        ans %= 10 ** 9 + 7

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

print(ans)


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

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

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

def main():
  read = stdin.readline
  N = int(read())
  data = list(map(int,read().split(" ")))
  ans = 1
  flg = False
  for i in data:
    if ans >= (10**18)/i:
      print("-1")
      flg = True
      break
    else:
      ans *= i
      
  if not flg:  
    print(ans)
  
  
if __name__ == "__main__":
  main()

from sys import stdin

def main():
  read = stdin.readline
  N = int(read())
  data = list(map(int,read().split(" ")))
  ans = 1
  flg = False
  for i in data:
    if ans*i >= 10**18:
      print("-1")
      flg = True
      break
    else:
      ans *= i
      
  if not flg:  
    print(ans)
  
  
if __name__ == "__main__":
  main()

from sys import stdin

def main():
  read = stdin.readline
  N = int(read())
  data = list(map(int,read().split(" ")))
  ans = 1
  flg = False
  if 0 in data:
    print("0")
    flg = True
    exit()
  for i in data:
    
    if ans*i > 10**18:
      print("-1")
      flg = True
      break
    else:
      ans *= i
      
  if not flg:  
    print(ans)
  
  
if __name__ == "__main__":
  main()

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input().split()))
a.sort()
z = mult(a)
print(z)


def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input.split()))
a.sort()
z = mult(m)
print(z)


def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input().split()))
a.sort()
z = mult(a)
print(z)


def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input.split()))
a.sort()
z = mult(a)
print(z)


def mult(m):
  s = 1
  for x in m:
    s = s * x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input().split()))
a.sort()
z = mult(m)
print(z)

def mul(m) : 
      
    # Multiply elements one by one 
    res = 1
    for x in m: 
        res = res * x
        if res == 0:
             return 0 
        if res > 10**18:
             return -1
    return res
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
z = mul(a)
print(z)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
n = int(input())
la = list(map(int, input().split()))
import sys
if la.index(0) > 0:
  print(0)
  sys.exit()

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

n = int(input())
la = list(map(int, input().split()))
la.sort()
ans = 1
for i in la:
  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):
lines = []
for i in range(2):
    lines.append(input())
num = int(lines[0])

out = 1
split = lines[1].split()
if "0" in split:
    out = 0
for i in range(num):
    print(out)
    out = int(split[i]) * out 
    if out > 1000000000000000000:
        out = - 1
        break 
print(out)

lines = []
for i in range(2):
    lines.append(input())
num = int(lines[0])

out = 1
split = lines[1].split()
for i in range(num):
    print(out)
    out = int(split[i]) * out 
if out > 1000000000000000000:
    out = - 1    
print(out)

lines = []
for i in range(2):
    lines.append(input())
num = int(lines[0])

out = 1
split = lines[1].split()
if "0" in split:
    out = 0
for i in range(num):
    out = int(split[i]) * out 
    if out > 1000000000000000000:
        out = - 1    
        break
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):
def pyn():
	n = int(input())
	a = list(map(int, input().split()))
    if 0 in a:
      print(0)
      return
    
	ans=1
	for i in a:
 	 	ans *= i
		if ans>10**18:
  			print(-1)
            return
	print(ans)


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

pyn()

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

r = a[0]

for i in a[1:]:
  r *= i
  if r > 10**8:
    r = -1
    break

if 0 in a:
  r = 0
    
print(r)

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
from operator import mul
from functools import reduce

N = int(input())
x = [int(input()) for i in range(N)]
y = reduce(mul, x)

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

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

num = 1

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

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

print(num)

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    total *= a
    if a==0:
        B = True
        break
if total>10**18 or not B:
    print(-1)
    sys.exit()
print(total)

import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    elif total <=10**18:
        total *= a
    else:
        B = True
if B or total>10**18:
    print(-1)
else:
    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):
import numpy
N = int(input())
lst = list(map(int,input().split()))
if N == len(lst) :
    output = numpy.prod(lst)
    if output <= 10**8 :
        print(output)
    else :
        print(-1)
else :
    exit()


A,B  = map(float, input().split())
print(int(A * B))
N = int(input())
lst = list(map(int, input().split()))
res = 1
if 0 in lst:
    res = 0
for x in lst:
    res *= x
    if res > 10**18:
        res = -1
print(res)

a, b = map(float, input().split())
print(int(a * b))
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    res = 0
for x in ls:
    res *= x
    if res > 10**18:
        res = -1
print(res)

N = int(input())
lst = list(map(int,input().split())
output = 1
if 0 in lst :
	print(0)
    quit()
for x in lst :
	output = output * x           
    if output > 10**8 :
    	print(-1)
        quit()
print(output)

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

N = int(input())
lst = list(map(int, input().split()))
output = 1
if 0 in lst:
    print(0)
    quit()
for i in ls:
    output *= i
    if output > 10**18:
        print(-1)
        quit()
print(output)

n = int(input())
lst = list(map(int, input().split()))
output = 1
if 0 in lst:
    print(0)
    quit()
for x in lst:
    output = output * x
    if res > 10**18:
        print(-1)
        quit()
print(output)


a, b = map(float, input().split())
print(int(a * b))
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    res = 0
for x in ls:
    res *= x
    if res > 10**18:
        res = -1
print(res)

from functools import reduce
N = int(input())
lst = list(map(int,input().split()))
if N == len(lst) :
    output = reduce((lambda x,y: x*y),lst)
    if output <= 10**8 :
        print(output)
    else :
        print(-1)
else :
    exit()

n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    print(0)
    quit()
for x in ls:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted