buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
n = int(input()) li = list(map(int,input().split())) li.sort() ans = 1 for i in range(n): ans = ans*li[i] if ans >= 10**18: ans = -1 break print(ans)
n = int(input()) li = list(map(int,input().split())) li.sort() ans = 1 for i in range(n): ans = ans*li[i] if ans > 10**18: ans = -1 break print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
65
# -*- coding: utf-8 -*- from decimal import Decimal # input n = int(input()) a = list(map(int, input().split())) out = 1 if 0 in a: print(0) quit() for i in range(n): out = Decimal(out * a[i]) if out > Decimal(10**18): print(-1) print(out)
# -*- coding: utf-8 -*- from decimal import Decimal # input n = int(input()) a = list(map(int, input().split())) out = 1 if 0 in a: print(0) quit() for i in range(n): out = Decimal(out * a[i]) if out > Decimal(10**18): print(-1) quit() print(out)
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
84
N = int(input()) A = list(map(int,input().split())) def f(A): for a in A: if a == 0: print(-1) return v = 1 for a in A: v *= a if v > int(1e+18): print(-1) return print(v) return f(A)
N = int(input()) A = list(map(int,input().split())) def f(A): for a in A: if a == 0: print(0) return v = 1 for a in A: v *= a if v > int(1e+18): print(-1) return print(v) return f(A)
[["-", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
81
def solve(): n = int(input()) a = list(map(int, input().split())) if 0 in A: print(0) return x = 1 for tmp in a: x *= tmp if x > 1000000000000000000: print(-1) return print(x) solve()
def solve(): n = int(input()) a = list(map(int, input().split())) if 0 in a: print(0) return x = 1 for tmp in a: x *= tmp if x > 1000000000000000000: print(-1) return print(x) solve()
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22]]
5
69
N = 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 elif result <= 10**18: continue else: print(result)
N = 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)
[["-", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683], ["+", 0, 57, 75, 76, 8, 196, 0, 57, 0, 121], ["-", 0, 7, 8, 196, 0, 57, 75, 665, 0, 102], ["-", 0, 57, 75, 665, 64, 196, 0, 116, 0, 117], ["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95]]
5
71
import sys N = int(input()) array = list(map(int,input().split())) if not ( 2 <= N <= 10**5 ): sys.exit() if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit() if 0 in array: print(0); sys.exit() sum = array[0] for I in range(1,len(array)): sum *= array[I] if sum >= 10**18: print(-1);sys.exit() print...
import sys N = int(input()) array = list(map(int,input().split())) if not ( 2 <= N <= 10**5 ): sys.exit() if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit() if 0 in array: print(0); sys.exit() sum = array[0] for I in range(1,len(array)): sum *= array[I] if sum > 10**18: print(-1);sys.exit() print(...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
131
cnt = gets.to_i max = 10**18 inputs = gets.split.map(&:to_i).sort.reverse if inputs.include?(0) result = -1 else result = 1 for i in 0..cnt-1 result *= inputs[i] if result > max result = -1 break end end end p result
cnt = gets.to_i max = 10**18 inputs = gets.split.map(&:to_i).sort.reverse if inputs.include?(0) result = 0 else result = 1 for i in 0..cnt-1 result *= inputs[i] if result > max result = -1 break end end end p result
[["-", 0, 121, 64, 749, 0, 662, 12, 748, 17, 33], ["-", 0, 121, 64, 749, 0, 662, 12, 748, 439, 612], ["+", 0, 493, 0, 121, 64, 749, 0, 662, 12, 612]]
4
68
n = int(input()) arr = list(map(int, input().split())) if 0 in arr: print(0 + '\n') else: mul = 1 for n in arr: mul *= n if mul > 10**18: print(-1 + '\n') break else: print(mul + '\n')
n = int(input()) arr = list(map(int, input().split())) if 0 in arr: print('0' + '\n') else: mul = 1 for n in arr: mul *= n if mul > 10**18: print('-1' + '\n') break else: print(str(mul) + '\n')
[["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 654], ["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 655], ["-", 0, 652, 3, 4, 0, 657, 31, 664, 17, 33], ["-", 0, 652, 3, 4, 0, 657, 31, 664, 28, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 6], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["...
5
78
N = int(input()) A = list(map(int,input().split())) m = 10 ** 18 ans = 1 if 0 in A: print(0) else: for i in range(N): if A[i] >= m: print(-1) exit() A = sorted(A) A = reversed(A) for i in A: ans *= i if ans > m: ans = -1 print(ans)
N = int(input()) A = list(map(int,input().split())) m = 10 ** 18 ans = 1 if 0 in A: print(0) else: for i in range(N): if A[i] >= m: print(-1) exit() A = sorted(A) A = reversed(A) for i in A: ans *= i if ans > m: ans = -1 break ...
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
101
n = int(input()) a = list(map(int, input().split())) limit = 10**18 ans = 1 flag = True if 0 in a: print(0) flag = False if flag: for i in a: ans *= i if ans >= limit: print(-1) flag = False break if flag: print(ans)
n = int(input()) a = list(map(int, input().split())) limit = 10**18 ans = 1 flag = True if 0 in a: print(0) flag = False if flag: for i in a: ans *= i if ans > limit: print(-1) flag = False break if flag: print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
80
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; vector<ll> A(N); ll ans = 1; for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] == 0) { cout << 0 << endl; return 0; } } for (int i = 0; i < N; i++) { //掛けた桁数が18桁を超える場合は-1を出力 ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; vector<ll> A(N); ll ans = 1; for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] == 0) { cout << 0 << endl; return 0; } } for (int i = 0; i < N; i++) { //掛けた桁数が18桁を超える場合は-1を出力 ...
[["-", 0, 57, 15, 339, 51, 16, 12, 2, 63, 22], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 24], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 13], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 21], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
162
N = int(input()) A = [int(i) for i in 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([int(i) for i in input().split()]) ans = 1 for i in range(N): ans *= A[i] if ans > 10**18: print(-1) break else: print(ans)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
62
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespac...
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespac...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 15, 339, 51, 16, 12, 16, 31, 74, 0, 24], ["+", 51, 16, 12, 16, 31, 74, 39, 77, 39, 78], ["+", 15, 339, 51, 16, 12, 16, 31, 74, 0, 25]]
1
201
N = int(input()) A = [int(x) for x in input().split()] result = 1 flag = 1 if A.count(0) == 0: for x in range(N): result = result * A[x] if result >= 10**18 + 1: print(0) exit() print(result) else: print(0)
N = int(input()) A = [int(x) for x in input().split()] result = 1 if A.count(0) == 0: for x in range(N): result = result * A[x] if result >= 10**18 + 1: print(-1) exit() print(result) else: print(0)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612]]
5
84
N = int(input()) ans = 1 S = list(map(int, input().split())) if 0 in S: ans = 0 else: for i in range(N): ans *= S[i-1] if ans >= 10**18: ans = -1 break print(ans)
N = int(input()) ans = 1 S = list(map(int, input().split())) if 0 in S: ans = 0 else: for i in range(N): ans *= S[i-1] if ans > 10**18: ans = -1 break print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
70
#include <algorithm> #include <iostream> #include <stdio.h> #include <vector> typedef long long ll; using namespace std; int main() { int n; cin >> n; long double total = 1; ll a; for (int i = 0; i < n; i++) { cin >> a; if (total != -1) { total *= a; } if (total > 1000000000000000000 |...
#include <algorithm> #include <iostream> #include <stdio.h> #include <vector> typedef long long ll; using namespace std; int main() { int n; cin >> n; long double total = 1; ll a; for (int i = 0; i < n; i++) { cin >> a; if (total != -1) { total *= a; } if (total > 1000000000000000000 |...
[["+", 0, 1, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 12, 74, 39, 77, 39, 78], ["+", 0, 1, 0, 16, 31, 16, 12, 74, 0, 25]]
1
108
import sys N = int(input()) A = list(map(int,input().split())) mul = A[0] for i in range(1,N): mul *= A[i] if mul > 10**18: print(-1) sys.exit() print(mul)
import sys N = int(input()) A = list(map(int,input().split())) A.sort() mul = A[0] for i in range(1,N): mul *= A[i] if mul > 10**18: print(-1) sys.exit() print(mul)
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
70
#include <bits/stdc++.h> #define INF 2147483640 using namespace std; long long a[100015]; int main() { // freopen("out.txt","w",stdout); int n, zero = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (!a[i]) zero++; } if (zero) { cout << 0 << '\n'; return 0; } long long c...
#include <bits/stdc++.h> #define INF 2147483640 using namespace std; long long a[100015]; int main() { // freopen("out.txt","w",stdout); int n, zero = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (!a[i]) zero++; } if (zero > 0) { cout << 0 << '\n'; return 0; } long lo...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
150
N = int(input()) A = list(map(int,input().split())) result = 1 for i in range(N): result = result * A[i] if result > 1e18: result = -1 break print(result)
N = int(input()) A = list(map(int,input().split())) A.sort() result = 1 for i in range(N): result = result * A[i] if result > 1e18: result = -1 break print(result)
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
58
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef pair<int, int> ii; typedef long long ll; typedef pair<ll, ll> p; typedef unsign...
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef pair<int, int> ii; typedef long long ll; typedef pair<ll, ll> p; typedef unsign...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
299
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; unsigned long long ans = 1; vector<unsigned long long> data(n); for (int i = 0; i < n; i++) { cin >> data.at(i); } sort(data.begin(), data.end()); for (int i = 0; i < n; i++) { if (data.at(i) > 1000000000000000000 / an...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; unsigned long long ans = 1; vector<unsigned long long> data(n); for (int i = 0; i < n; i++) { cin >> data.at(i); } sort(data.begin(), data.end()); for (int i = 0; i < n; i++) { if (data.at(i) > 1000000000000000000 / an...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 13]]
1
143
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(Syste...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(Syste...
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 15, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 22]]
3
244
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) #define cint(a) \ int a; \ cin >> a; #define cstr(str) ...
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) #define cint(a) \ int a; \ cin >> a; #define cstr(str) ...
[["-", 15, 339, 51, 16, 12, 16, 31, 23, 0, 24], ["-", 15, 339, 51, 16, 12, 16, 31, 23, 0, 25], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
206
N = int(input()) A =[i for i in map(int, input().split())] if a.count(0) != 0: print(0) else: result = 1 for i in range(N): result *= A[i] if result > (10**18): print(-1) break else: continue else: print(result)
n = int(input()) a = [i for i in map(int, input().split())] if a.count(0) != 0: print(0) else: result = 1 for i in range(n): result *= a[i] if result > (10**18): print(-1) break else: continue else: print(result)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22]]
5
85
n = int(input()) a = list(map(int, input().split())) if a.count(0) != 0: print(0) else: result = 1 for i in range(n): result *= a[i] if result > 10^(18): print(-1) break else: continue else: print(result)
n = int(input()) a = list(map(int, input().split())) if a.count(0) != 0: print(0) else: result = 1 for i in range(n): result *= a[i] if result > (10**18): print(-1) break else: continue else: print(result)
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 31, 612], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 140], ["+", 0, 57, 15, 666, 0, 23, 0, 657, 31, 612], ["+", 0, 57, 15, 666, 0, 23, 0, 657, 17, 578]]
5
82
input() l = list(map(int, input().split())) r = 1 for i in l: r *= i if r > 10 ** 18: print('-1') exit(0) print(r)
input() l = list(map(int, input().split())) l.sort() r = 1 for i in l: r *= i if r > 10 ** 18: print('-1') exit(0) print(r)
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
52
import sys n = input() a = list(map(int, input().split())) if 0 in a: pirnt(0) sys.exit(0) s = 1 for x in a: s *= x if s > 1000000000000000000: break if s > 1000000000000000000: print(-1) else: print(s)
import sys n = input() a = list(map(int, input().split())) if 0 in a: print(0) sys.exit(0) s = 1 for x in a: s *= x if s > 1000000000000000000: break if s > 1000000000000000000: print(-1) else: print(s)
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22]]
5
72
def b169(n, alist): ans = 1 for i in alist: if i == 0: return 0 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()
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__ == '__mai...
[["+", 0, 656, 0, 14, 8, 196, 0, 7, 0, 88], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 0, 267], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 12, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 0, 102]]
5
87
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n]; long ans = 1; long max = (long)Math.pow(10, 18); for (int i = 0; i < n; i++) { a[i] = sc.nextLong(); if (a[i] == 0) {...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n]; long ans = 1; long max = (long)Math.pow(10, 18); for (int i = 0; i < n; i++) { a[i] = sc.nextLong(); if (a[i] == 0) {...
[["-", 64, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["+", 0, 1, 0, 492, 3, 4, 0, 91, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 91, 439, 499]]
3
193
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)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
70
def main(numbers: list): result = 1 for num in numbers: result *= num if result > 10 ** 18: print(-1) return print(result) N = int(input()) line = list(map(int, input().split())) main(line)
def main(numbers: list): result = 1 numbers.sort() for num in numbers: result *= num if result > 10 ** 18: print(-1) return print(result) N = int(input()) line = list(map(int, input().split())) main(line)
[["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
65
n = gets.to_i a = gets.split.map(&:to_i) ans = 1 MAX = 10 ** 18 a.each do |ai| ans *= ai if ans > MAX puts -1 exit end end puts ans
n = gets.to_i a = gets.split.map(&:to_i).sort ans = a.shift MAX = 10 ** 18 a.each do |ai| ans *= ai if ans > MAX puts -1 exit end end puts ans
[["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22], ["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 22]]
4
46
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 if 0 in a: print(0) exit() for a in a: res *= a if res > 1e18: res = -1 break print(res)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
59
n = int(input()) l = list(map(int,input().split())) count = 1 if l.count(0) != 0: print(0) else: for i in range(n): count *= l[i] if count >= 1000000000000000000: print("-1") break if count <= 1000000000000000000: print(count)
n = int(input()) l = list(map(int,input().split())) count = 1 if l.count(0) != 0: print(0) else: for i in range(n): count *= l[i] if count > 1000000000000000000: print("-1") break if count <= 1000000000000000000: print(count)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
79
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード //ループ #define REP(i, n) for (int i = 0; i < n; i++) //普通のループ #define REPR(i, n) for (int i = n; i >= 0; i--) //逆ループ #define FOR(i, m, n) for (int i = m; i < n; i++) //最初の数値を指定したループ //型名省略 typedef long long ll; //配列要素数 static const int MAX = 200000; //値 static const ll ...
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード //ループ #define REP(i, n) for (int i = 0; i < n; i++) //普通のループ #define REPR(i, n) for (int i = n; i >= 0; i--) //逆ループ #define FOR(i, m, n) for (int i = m; i < n; i++) //最初の数値を指定したループ //型名省略 typedef long long ll; //配列要素数 static const int MAX = 200000; //値 static const ll ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
272
input = readlines() total = input.shift().chomp.to_i list = input.shift().chomp.split("\s").map{|x| x.to_i} res = nil list.each do |l| if res.nil? res = l next end res *= l if res > 10**18 puts '-1' exit() end end puts res
input = readlines() total = input.shift().chomp.to_i list = input.shift().chomp.split("\s").map{|x| x.to_i} res = nil list.sort().each do |l| if res.nil? res = l next end res *= l if res > 10**18 puts '-1' exit() end end puts res
[["+", 36, 36, 0, 493, 0, 652, 486, 652, 735, 22], ["+", 0, 493, 0, 652, 486, 652, 3, 4, 0, 24], ["+", 0, 493, 0, 652, 486, 652, 3, 4, 0, 25], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 17, 131]]
4
81
N=int(input()) X=list(map(int, input().split())) ans=1 if 0 in X: print(0) else: X.sorted(reverse = True) for i in range(N): ans *= X[i] if 10**18<ans: print(-1) break else: print(ans)
N=int(input()) X=list(map(int, input().split())) ans=1 if 0 in X: print(0) else: X.sort(reverse = True) for i in range(N): ans *= X[i] if 10**18<ans: print(-1) break else: print(ans)
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22]]
5
80
N=int(input()) X=list(map(int, input().split())) ans=1 if 0 in X: print(0) else: for i in range(N): ans *= X[i] print(ans) if 10**18<ans: print(-1) break else: print(ans)
N=int(input()) X=list(map(int, input().split())) ans=1 if 0 in X: print(0) else: for i in range(N): ans *= X[i] if 10**18<ans: print(-1) break else: print(ans)
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
76
n = int(input()) a = [int(x) for x in input().split()] ans = 1 ok = True for i in range(n): ans *= a[i] if ans > 10 ** 18: ok = False break for i in range(N): if a[i] == 0: ok = True ans = 0 if ok == True: print(ans) else: print(-1)
n = int(input()) a = [int(x) for x in input().split()] ans = 1 ok = True for i in range(n): ans *= a[i] if ans > 10 ** 18: ok = False break for i in range(n): if a[i] == 0: ok = True ans = 0 if ok == True: print(ans) else: print(-1)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
95
#include <bits/stdc++.h> using namespace std; typedef long long ll; const long long INF = 1LL << 60; // intじゃ扱えないことに注意! using P = pair<int, int>; #define rep(i, n) \ for (int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意! const ll MX = 1e18; int main() { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const long long INF = 1LL << 60; // intじゃ扱えないことに注意! using P = pair<int, int>; #define rep(i, n) \ for (int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意! const ll MX = 1e18; int main() { ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
138
n = gets.chomp.to_i ai = gets.chomp.split.map(&:to_i) INF = 10**18 ans = 1 ai.each do |a| ans *= a if ans>INF ans = -1 break end end p ans
n = gets.chomp.to_i ai = gets.chomp.split.map(&:to_i).sort INF = 10**18 ans = 1 ai.each do |a| ans *= a if ans>INF ans = -1 break end end p ans
[["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]]
4
51
n = int(input()) a = list(map(int,input().split())) p = 1 for i in range(n): if a[i] == 0: print(0) exit() for j in range(n): p *= a[i] if p > 10**18: print(-1) exit() print(p)
n = int(input()) a = list(map(int,input().split())) p = 1 for i in range(n): if a[i] == 0: print(0) exit() for j in range(n): p *= a[j] if p > 10**18: print(-1) exit() print(p)
[["-", 8, 196, 0, 1, 0, 677, 12, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 206, 22]]
5
84
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void) { int N; cin >> N; vector<ll> A; for (int i = 0; i < N; i++) { ll tmp; cin >> tmp; if (tmp == 0) { cout << 0 << endl; return 0; } A.push_back(tmp); } ll mul = 1; for (int i = 0; i < N; i+...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void) { int N; cin >> N; vector<ll> A; for (int i = 0; i < N; i++) { ll tmp; cin >> tmp; if (tmp == 0) { cout << 0 << endl; return 0; } A.push_back(tmp); } ll mul = 1; for (int i = 0; i < N; i+...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
141
num = int(input()) nums = input().split() zero_flag = False for item in nums: if item == '0': zero_flag = True break if zero_flag: seki = 0 else: seki = 1 for item in nums: seki *= int(item) print(seki) if seki > 10**18: seki = -1 break print(seki)
num = int(input()) nums = input().split() zero_flag = False for item in nums: if item == '0': zero_flag = True break if zero_flag: seki = 0 else: seki = 1 for item in nums: seki *= int(item) if seki > 10**18: seki = -1 break print(seki)
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
78
#include <bits/stdc++.h> using namespace std; int main() { long long int N; string S; cin >> N; vector<long long int> A(N); for (long long int i = 0; i < N; i++) cin >> A[i]; for (long long int i = 0; i < N; i++) { if (A[i] == 0) { cout << 0 << endl; return 0; } } long long in...
#include <bits/stdc++.h> using namespace std; int main() { long long int N; string S; cin >> N; vector<long long int> A(N); for (long long int i = 0; i < N; i++) cin >> A[i]; for (long long int i = 0; i < N; i++) { if (A[i] == 0) { cout << 0 << endl; return 0; } } long long in...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
157
#include <bits/stdc++.h> #include <fstream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(20) << fixed; /* ifstream in("input.txt"); cin.rdbuf(in.rdbuf()); //*/ int N; cin >> N; long long ans = 1; vector<long long> A(N); for (int i = 0; i < N; ...
#include <bits/stdc++.h> #include <fstream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(20) << fixed; /* ifstream in("input.txt"); cin.rdbuf(in.rdbuf()); //*/ int N; cin >> N; long long ans = 1; vector<long long> A(N); for (int i = 0; i < N; ...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
164
N = int(input()) A = list(map(int, input().split())) ans =1; iszero = False if 0 in A: iszero = True for i in range(N): if(iszero): ans = 0 break ans *= A[i] if ans>10**18: ans = -1 print(ans)
N = int(input()) A = list(map(int, input().split())) ans =1; iszero = False if 0 in A: iszero = True for i in range(N): if(iszero): ans = 0 break ans *= A[i] if ans>10**18: ans = -1 break print(ans)
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
78
N, A = map(int, open(0).read().split()) if 0 in A: print(0) exit() ans = 1 for a in A: ans *= a if ans > 10 ** 18: print(-1) break else: print(ans)
N, *A = map(int, open(0).read().split()) if 0 in A: print(0) exit() ans = 1 for a in A: ans *= a if ans > 10 ** 18: print(-1) break else: print(ans)
[["+", 0, 1, 0, 662, 31, 684, 0, 695, 0, 48]]
5
63
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if ...
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if ...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
176
#input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def get_nsp() retu...
#input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def get_nsp() retu...
[["-", 196, 737, 8, 736, 0, 121, 15, 738, 17, 20], ["+", 196, 737, 8, 736, 0, 121, 15, 738, 17, 47]]
4
239
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) ll LINF = 1e18; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> a(n); REP(i, n) { cin >> a[i]; } sort(a.begin(), a.end()); if (a[0] == 0) { co...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) ll LINF = 1e18; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> a(n); REP(i, n) { cin >> a[i]; } sort(a.begin(), a.end()); if (a[0] == 0) { co...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
164
#include <bits/stdc++.h> using namespace std; long long INF = 1e18; int main() { long long N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] == 0) { cout << 0 << endl; return 0; } } long long ans = 1; for (int i = 0; i < N; i++) { if (INF / A[i]...
#include <bits/stdc++.h> using namespace std; long long INF = 1e18; int main() { long long N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] == 0) { cout << 0 << endl; return 0; } } long long ans = 1; for (int i = 0; i < N; i++) { if (INF ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96]]
1
135
n = int(input()) a = 1 s = list(map(int, input().split())) if 0 in s: print(0) exit() for i in s: a*=s[i] if a>10**18: print(-1) exit() else: print(a)
n = int(input()) a = 1 s = list(map(int, input().split())) if 0 in s: print(0) exit() for i in s: a*=i if a>10**18: print(-1) exit() else: print(a)
[["-", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 677, 12, 206, 0, 70], ["-", 8, 196, 0, 1, 0, 677, 12, 206, 0, 73]]
5
72
#include <stdio.h> int main(void) { long long int i, x = 1, N, A[100001]; scanf("%lld", &N); for (i = 0; i < N; i++) { scanf("%lld", &A[i]); } for (i = 0; i < N; i++) { if (A[i] == 0) { x = 0; puts("0"); return 0; } } for (i = 0; i < N; i++) { if (x > powl(10, 18) / A...
#include <stdio.h> int main(void) { long long int i, x = 1, N, A[100001]; scanf("%lld", &N); for (i = 0; i < N; i++) { scanf("%lld", &A[i]); } for (i = 0; i < N; i++) { if (A[i] == 0) { x = 0; puts("0"); return 0; } } for (i = 0; i < N; i++) { if (x <= powl(10, 18) / ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19]]
0
168
#include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long using namespace std; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a.at(i); if (a.at(i) == 0) { cout << 0 << endl; return 0; } } ll max = 100000000000000000...
#include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long using namespace std; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a.at(i); if (a.at(i) == 0) { cout << 0 << endl; return 0; } } ll max = 100000000000000000...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
147
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; ll a[100005]; ll ans = 1; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << "0" << endl; return 0; } } for (int i = 0; i < n; i++) { if (ans * a[i] <= 10000000000...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; ll a[100005]; ll ans = 1; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << "0" << endl; return 0; } } for (int i = 0; i < n; i++) { if (a[i] <= 10000000000000000...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
140
n = int(input()) a= list(map(int,input().split())) c = 1 if 0 in a: print(0) else: for x in a: if x >10**18: print(-1) break else: c*=x if c >10**18: print(-1) break else: print(z)
n = int(input()) a= list(map(int,input().split())) c = 1 if 0 in a: print(0) else: for x in a: if x >10**18: print(-1) break else: c*=x if c >10**18: print(-1) break else: print(c)
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
81
n = int(input()) a= list(map(int,input().split())) c = 1 if 0 in a: print(0) else: for x in a: if x >10**18: print(-1) break else: z = x*c c = z if z >10**18: print(-1) break print(z)
n = int(input()) a= list(map(int,input().split())) c = 1 if 0 in a: print(0) else: for x in a: if x >10**18: print(-1) break else: z = x*c c = z if z >10**18: print(-1) break else: print(z)
[["+", 75, 76, 8, 196, 0, 7, 75, 76, 0, 95], ["+", 75, 76, 8, 196, 0, 7, 75, 76, 0, 102]]
5
84
n = int(input()) a = map(int,input().split()) a.sort() t = 1 for i in range(len(a)): t *= a[i] if t > 10**18: break if t > 10**18 : print("-1") else: print(str(t))
n = int(input()) a = list(map(int,input().split())) a.sort() t = 1 for i in range(len(a)): t *= a[i] if t > 10**18: break if t > 10**18 : print("-1") else: print(str(t))
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
77
#include <bits/stdc++.h> using namespace std; using ll = long long; #include <math.h> double log10(double x); int main() { int n; cin >> n; int64_t a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << -1 << endl; return 0; } } int64_t ans = 1LL; /* for (int i =...
#include <bits/stdc++.h> using namespace std; using ll = long long; #include <math.h> double log10(double x); int main() { int n; cin >> n; int64_t a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << 0 << endl; return 0; } } int64_t ans = 1LL; /* for (int i = ...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
162
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); long double count = 0; for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); for (int i = 0; i < N; i++) { if (A[i] == 0) { cout << 0 << endl; return 0; } count += l...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<long double> A(N); long double count = 0; for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); for (int i = 0; i < N; i++) { if (A[i] == 0) { cout << 0 << endl; return 0; } co...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87]]
1
191
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long long sum = 1; long long oba = 1; int P = 0; bool huro = false; bool mu = false; for (int X = 0; X < N; X++) { long long I; cin >> I; string size = to_string(I); P += size.size() - 1; if (I == 0) { ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long long sum = 1; long long oba = 1; int P = 0; bool huro = false; bool mu = false; for (int X = 0; X < N; X++) { long long I; cin >> I; string size = to_string(I); P += size.size() - 1; if (I == 0) { ...
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
179
N = int(input()) A = list(map(int, input().split())) prod = 1 for i in range(N): prod *= A[i] if prod > 10**18: prod = -1 break elif prod == 0: break print(prod)
N = int(input()) A = list(map(int, input().split())) A.sort() prod = 1 for i in range(N): prod *= A[i] if prod > 10**18: prod = -1 break elif prod == 0: break print(prod)
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
64
n = int(input()) a = list(map(int,input().split())) if 0 in a: print(0) else: ans = 1 for val in a: ans *= val if ans > 10**18: print(-1) print(ans)
n = int(input()) a = list(map(int,input().split())) if 0 in a: print(0) else: ans = 1 for val in a: ans *= val if ans > 10**18: print(-1) exit() print(ans)
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
63
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #define initdp(a, b) \ for (int i = 0; i <= a; i++) \ for (int j = 0; j <= b; j++) \ ...
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #define initdp(a, b) \ for (int i = 0; i <= a; i++) \ for (int j = 0; j <= b; j++) \ ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
278
#include <algorithm> #include <bitset> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <tuple> #include <vector> using namespace std; int main() { int n; cin >> n; int64_t a[n]; int i, zero = 0; for (i = 0; i < n; i++) { cin >> a[i]; if ...
#include <algorithm> #include <bitset> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <tuple> #include <vector> using namespace std; int main() { int n; cin >> n; int64_t a[n]; int i, zero = 0; for (i = 0; i < n; i++) { cin >> a[i]; if ...
[["-", 51, 16, 12, 23, 0, 16, 31, 2, 63, 22], ["-", 12, 23, 0, 16, 31, 2, 3, 4, 0, 24], ["-", 12, 23, 0, 16, 31, 2, 3, 4, 0, 13], ["-", 12, 23, 0, 16, 31, 2, 3, 4, 0, 21], ["-", 12, 23, 0, 16, 31, 2, 3, 4, 0, 25], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 31, 13]]
1
166
n = int(input()) A = [int(i) for i in input().split()] product = 1 for i in range(n): product *= A[i] if(product > 10**18): print("-1") break if(product <= 10**18): print(product)
n = int(input()) A = [int(i) for i in input().split()] product = 1 A.sort() for i in range(n): product *= A[i] if(product > 10**18): print("-1") break if(product <= 10**18): print(product)
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
72
import sys N = int(input()) L = list(map(int, input().split())) cnt = 1 if 0 in L: print(0) sys.exit() for i in range(N): cnt *= L[i] if cnt > 10^18: print(-1) sys.exit() print(cnt)
import sys N = int(input()) L = list(map(int, input().split())) cnt = 1 if 0 in L: print(0) sys.exit() for i in range(N): cnt *= L[i] if cnt > 10**18: print(-1) sys.exit() print(cnt)
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 140], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 578]]
5
79
#include <algorithm> #include <cstdlib> #include <cstring> #include <iostream> #include <math.h> #include <vector> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; i++) int main() { ll n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; ll p, q; p = 1; rep(i, n) p *= a[...
#include <algorithm> #include <cstdlib> #include <cstring> #include <iostream> #include <math.h> #include <vector> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; i++) int main() { ll n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; ll p, q; p = 1; rep(i, n) p *= a[...
[["-", 15, 339, 51, 16, 12, 16, 12, 2, 63, 22], ["-", 51, 16, 12, 16, 12, 2, 3, 4, 0, 24], ["-", 51, 16, 12, 16, 12, 2, 3, 4, 0, 13], ["-", 51, 16, 12, 16, 12, 2, 3, 4, 0, 21], ["-", 51, 16, 12, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
190
N = int(input()) A = list(map(int, input().split())) ans = A[0] if A.count(0) != 0: ans = 0 else: for i in range(1,N): ans = ans * A[i] if ans >= 10 ** 18: ans = -1 break print(ans)
N = int(input()) A = list(map(int, input().split())) ans = A[0] if A.count(0) != 0: ans = 0 else: for i in range(1,N): ans = ans * A[i] if ans > 10 ** 18: ans = -1 break print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
80
ans_max = 10**18 N = gets.to_i A = gets.chomp.split(' ').map(&:to_i) if A.include?(0) puts -1 exit end ans = 1 A.each do |a| ans *= a if ans > ans_max puts -1 exit end end puts ans
ans_max = 10**18 N = gets.to_i A = gets.chomp.split(' ').map(&:to_i) if A.include?(0) puts 0 exit end ans = 1 A.each do |a| ans *= a if ans > ans_max puts -1 exit end end puts ans
[["-", 64, 749, 0, 652, 3, 4, 0, 748, 17, 33], ["-", 64, 749, 0, 652, 3, 4, 0, 748, 439, 612], ["+", 0, 121, 64, 749, 0, 652, 3, 4, 0, 612]]
4
65
N = int(input()) A = list(map(int,input().split(' '))) ans=1 thresh=10**18 for i in range(N): ans = ans * A[i] if ans > thresh: ans=-1 break print(ans)
N = int(input()) A = list(map(int,input().split(' '))) ans=1 thresh=10**18 A.sort() for i in range(N): ans = ans * A[i] if ans > thresh: ans=-1 break print(ans)
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
66
def mul2(): n = int(input()) a = list(map(int, input().split())) if 0 in a: return 0 ans = 1 for i in a: ans *= i if ans > 1000000000000000000: return -1 return ans mul2()
def mul2(): n = int(input()) a = list(map(int, input().split())) if 0 in a: return 0 ans = 1 for i in a: ans *= i if ans > 1000000000000000000: return -1 return ans print(mul2())
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
61
N = gets.to_i numbers = gets.strip.split(nil).map(&:to_i) i = 0 pr = 1 unless numbers.include?(0) then while i < N do if pr <= 10**18 then pr *= numbers[i] i += 1 else pr = -1 break end end if pr <= 10**18 then puts pr else puts "-1" end else pr = "0" end
N = gets.to_i numbers = gets.strip.split(nil).map(&:to_i) i = 0 pr = 1 unless numbers.include?(0) then while i < N do if pr <= 10**18 then pr *= numbers[i] i += 1 else pr = -1 break end end if pr <= 10**18 then puts pr else puts "-1" end else puts "0" end
[["-", 0, 493, 0, 747, 75, 95, 0, 662, 31, 22], ["-", 0, 493, 0, 747, 75, 95, 0, 662, 0, 32], ["+", 0, 493, 0, 747, 75, 95, 0, 652, 735, 22]]
4
86
n = int(input()) a = list(map(int, input().split())) a.sort() def main(a): if 0 in a: ans = 0 else: ans = 1 for item in a: ans *= item if ans > 1000000000000000000: ans = -1 return ans ans = main(a) print(ans)
n = int(input()) a = list(map(int, input().split())) a.sort() def main(a): if 0 in a: ans = 0 else: ans = 1 for item in a: ans *= item if ans > 1000000000000000000: ans = -1 break return ans ans = main(a) print(ans)
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
78
n = int(input()) x = list(map(int, input().split())) ans = x[0] if 0 in x: ans = 0 else: for i in range(1,n): ans = ans * x[i] if ans > 10 ** 18: ans = -1 print(ans)
n = int(input()) x = list(map(int, input().split())) ans = x[0] if 0 in x: ans = 0 else: for i in range(1,n): ans = ans * x[i] if ans > 10 ** 18: ans = -1 break print(ans)
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
74
n = int(input()) nums = list(map(int, input().split())) sum = 1 flag = 1 upper = pow(10, 18) for num in nums: if num == 0: sum = 0 break if flag == 1: sum = sum * num if sum > upper: flag = 2 if flag == 1: print(sum) elif flag == 2: print(-1)
n = int(input()) nums = list(map(int, input().split())) sum = 1 flag = 1 upper = pow(10, 18) for num in nums: if num == 0: sum = 0 flag = 1 break if flag == 1: sum = sum * num if sum > upper: flag = 2 if flag == 1: print(sum) elif flag == 2: print(-1)
[["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
5
90
#include <bits/stdc++.h> #define ll long long int #define rep(i, a, b) for (long long i = a; i < b; i += 1) #define repr(i, a, b) for (long long i = a; i <= b; i += 1) #define vec vector<ll> #define map map<char, int> #define repa(p, A) for (auto p : A) #define pb push_back #define sort(a) sort(a.begin(), a.end()) #def...
#include <bits/stdc++.h> #define ll long long int #define rep(i, a, b) for (long long i = a; i < b; i += 1) #define repr(i, a, b) for (long long i = a; i <= b; i += 1) #define vec vector<ll> #define map map<char, int> #define repa(p, A) for (auto p : A) #define pb push_back #define sort(a) sort(a.begin(), a.end()) #def...
[["+", 0, 30, 0, 14, 8, 9, 0, 9, 0, 46], ["-", 0, 30, 0, 14, 8, 9, 0, 9, 0, 46]]
1
187
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long mul = 1; long long a[n]; long long z = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) z = 1; } if (z == 1) { cout << 0; return 0; } for (int i = 0; i < n; i++) { if (mul * a[...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long mul = 1; long long a[n]; long long z = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) z = 1; } if (z == 1) { cout << 0; return 0; } for (int i = 0; i < n; i++) { if (a[i] <= ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
139
N=int(input()) A_list=sorted(list(map(int, input().split())), reverse=True) ans=1 if 0 in A_list: print(0) exit() else: for a in A_list: ans*=a if ans>1e+18: ans=-1 exit() print(ans)
N=int(input()) A_list=sorted(list(map(int, input().split())), reverse=True) ans=1 if 0 in A_list: print(0) exit() else: for a in A_list: ans*=a if ans>1e+18: print(-1) exit() print(ans)
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
73
n = int(input()) A = sorted(map(int,input().split()), reverse = True) print(A) if 0 in A: print(0) else: ans = 1 for i in A: ans *= i if ans >10**18: print(-1) else: print(ans)
n = int(input()) A = sorted(map(int,input().split()), reverse = True) if 0 in A: print(0) else: ans = 1 for i in A: ans *= i if ans >10**18: print(-1) break else: print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
73
"use strict"; const main = (input) => { const spi = input.split('\n'); const n = spi[0]; const a = spi[1].split(' ').map(e => BigInt(e)); a.sort(function(a, b) { return (a < b ? -1 : 1); }); const MAX = 1000000000000000000n; let ans = a[0]; for (let i = 1; i < n; i++) { ans *= a[i]; if (ans > M...
"use strict"; const main = (input) => { const spi = input.split('\n'); const n = spi[0]; const a = spi[1].split(' ').map(e => BigInt(e)); a.sort(function(a, b) { return (a < b ? -1 : 1); }); const MAX = 1000000000000000000n; let ans = a[0]; for (let i = 1; i < n; i++) { ans *= a[i]; if (ans > M...
[["+", 0, 2, 3, 3, 0, 2, 63, 558, 0, 131], ["+", 0, 2, 3, 3, 0, 2, 63, 558, 559, 560], ["+", 0, 2, 3, 3, 0, 2, 3, 3, 0, 24], ["+", 8, 556, 0, 1, 0, 2, 3, 3, 0, 25]]
2
168
n = int(input()) l = list(map(int, input().split())) if 0 in l: print(0) ans = 1 for i in range(n): ans *= l[i] if ans > 10**18: ans = -1 break print(ans)
n = int(input()) l = list(map(int, input().split())) if 0 in l: print(0) exit() ans = 1 for i in range(n): ans *= l[i] if ans > 10**18: ans = -1 break print(ans)
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
67
import sys read = sys.stdin.read readlines = sys.stdin.readlines from collections import deque def main(): n, *a = map(int, read().split()) if 0 in a: print(0) a = deque(a) s = 10 ** 18 r = 1 while a: r = r * a.popleft() if r > s: print(-1) sys.ex...
import sys read = sys.stdin.read readlines = sys.stdin.readlines from collections import deque def main(): n, *a = map(int, read().split()) if 0 in a: print(0) sys.exit() a = deque(a) s = 10 ** 18 r = 1 while a: r = r * a.popleft() if r > s: print(-1)...
[["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
106
def main(): n = int(input()) a = [int(s) for s in input().split()] ans = 1 if 0 in a: print(0) return for i in a: ans *= i print(ans) if ans > (10 ** 18): ans = -1 break print(ans) main()
def main(): n = int(input()) a = [int(s) for s in input().split()] ans = 1 if 0 in a: print(0) return for i in a: ans *= i if ans > (10 ** 18): ans = -1 break print(ans) main()
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
77
#include <algorithm> #include <cstdlib> #include <iostream> #include <sstream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { int n, i = 0, j = 0; long long int ans = 0; cin >> n; vector<long l...
#include <algorithm> #include <cstdlib> #include <iostream> #include <sstream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { int n, i = 0, j = 0; long long int ans = 0; cin >> n; vector<long l...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13]]
1
205
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int N; cin >> N; vector<ll> a(N); rep(i, N) cin >> a[i]; ll ans = 1; ll limit = pow(10, 18); // 0の確認 rep(i, N) { if (a[i] == 0) { cout << 0 << endl; return 0; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int N; cin >> N; vector<ll> a(N); rep(i, N) cin >> a[i]; ll ans = 1; ll limit = pow(10, 18); // 0の確認 rep(i, N) { if (a[i] == 0) { cout << 0 << endl; return 0; ...
[["-", 0, 57, 15, 339, 51, 16, 31, 74, 0, 24], ["-", 15, 339, 51, 16, 31, 74, 39, 77, 39, 40], ["-", 0, 57, 15, 339, 51, 16, 31, 74, 0, 25], ["-", 51, 16, 12, 16, 31, 74, 39, 77, 39, 40], ["-", 15, 339, 51, 16, 12, 16, 31, 74, 0, 25], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 25]]
1
154
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vi>; using ll = long long; const ll MX = 1e18; int main() { int n; cin >> n; vector...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vi>; using ll = long long; const ll MX = 1e18; int main() { int n; cin >> n; vector...
[["+", 31, 16, 12, 16, 31, 16, 31, 23, 0, 24], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 18], ["-", 51, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["-", 51, 16, 31, 16, 12, 16, 12, 16, 17, 48], ["+", 31, 16, 12, 16, 31, 16, 31, 23, 0, 25], ["+", 51, 16, 31, 16, 12, 16, 31, 16, 17, 85], ["+", 15, 339, 51, 16, 31, 16, 12, 16,...
1
245
#include <stdio.h> int main(void) { int N; long long a[100010]; int i; long long s = 1; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%lld", &a[i]); } int zero = 0; for (i = 0; i < N; i++) { if (a[i] == 0) { zero = zero + 1; } if (zero > 0) { printf("0\n"); return...
#include <stdio.h> int main(void) { int N; long long a[100010]; int i; long long s = 1; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%lld", &a[i]); } int zero = 0; for (i = 0; i < N; i++) { if (a[i] == 0) { zero = zero + 1; } if (zero > 0) { printf("0\n"); return...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19]]
0
185
import sys N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) res = 1 for a in A: res *= a if res > 1e18: print(-1) sys.exit() print(res)
import sys N = int(input()) A = list(map(int, input().split())) A.sort() res = 1 for a in A: res *= a if res > 1e18: print(-1) sys.exit() print(res)
[["-", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 653, 0, 32], ["-", 0, 1, 0, 652, 3, 4, 0, 653, 51, 146]]
5
65
#入力:[n1,n2,...nk](int:整数配列) def input_array(): return list(map(int,input().split())) def swap(a,b): tmp=a a=b b=tmp return a,b n=int(input()) A=input_array() MAX=10**18 A=sorted(A) ans=A[0] for i in range(1,len(A)): ans*=A[i] if ans==0: break elif ans>MAX: print(ans) ans=-1 break else: pass print(...
#入力:[n1,n2,...nk](int:整数配列) def input_array(): return list(map(int,input().split())) def swap(a,b): tmp=a a=b b=tmp return a,b n=int(input()) A=input_array() MAX=10**18 A=sorted(A) ans=A[0] for i in range(1,len(A)): ans*=A[i] if ans==0: break elif ans>MAX: ans=-1 break else: pass print(ans)
[["-", 75, 665, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
119
#include <cmath> #include <iostream> using namespace std; int main(void) { long long num = pow(10, 18); unsigned long long sum = 1; int N; cin >> N; bool check = false; for (int i = 0; i < N; i++) { int A; cin >> A; if (A == 0) { cout << 0 << endl; return 0; } // 10の18乗を超...
#include <cmath> #include <iostream> using namespace std; int main(void) { long long num = pow(10, 18); unsigned long long sum = 1; int N; cin >> N; bool check = false; for (int i = 0; i < N; i++) { long long A; cin >> A; if (A == 0) { cout << 0 << endl; return 0; } // 10...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22]]
1
131
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ...
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
97
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, ans = 1; bool t = true; cin >> n; int64_t a[n]; for (int64_t i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << 0 << endl; t = false; break; } } if (t) { for (int64_t i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, ans = 1; bool t = true; cin >> n; int64_t a[n]; for (int64_t i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << 0 << endl; t = false; break; } } if (t) { for (int64_t i = 0; i < n; i++) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
144
n=int(input()) A=list(map(int,input().split())) ans=1 if 0 in A: print(0);exit() for i in range(n): ans*=A[i] if ans>10**18: print(-1);exit() print(-1)
n=int(input()) A=list(map(int,input().split())) ans=1 if 0 in A: print(0);exit() for i in range(n): ans*=A[i] if ans>10**18: print(-1);exit() print(ans)
[["-", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
76
#include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define endl "\n...
#include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define endl "\n...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
165
#include <bits/stdc++.h> using namespace std; int main() { int N = 0; unsigned long long A = 0, ans = 1; vector<unsigned long long> vec; cin >> N; for (int i = 0; i < N; i++) { cin >> A; vec.push_back(A); } sort(vec.begin(), vec.end()); unsigned long long z = pow(10, 18); for (int x : vec...
#include <bits/stdc++.h> using namespace std; int main() { int N = 0; unsigned long long A = 0, ans = 1; vector<unsigned long long> vec; cin >> N; for (int i = 0; i < N; i++) { cin >> A; vec.push_back(A); } sort(vec.begin(), vec.end()); unsigned long long z = pow(10, 18); for (unsigned lo...
[["-", 0, 30, 0, 14, 8, 9, 0, 338, 39, 40], ["+", 0, 14, 8, 9, 0, 338, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 338, 39, 86, 0, 96]]
1
155
input() A = list(map(int, input().split())) A = A.sorted() p = 1 for i in A: p *= i if p > 10**18: p = -1 break print(p)
input() A = list(map(int, input().split())) A = sorted(A) p = 1 for i in A: p *= i if p > 10**18: p = -1 break print(p)
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
54
N=int(input()) vec=list(map(int,input().split())) vec.sort() print(vec) if(0 in vec): print(0) else: res = 1 for v in vec: res *= v if(res > 10**18): res = -1 break print(res)
N=int(input()) vec=list(map(int,input().split())) vec.sort() #print(vec) if(0 in vec): print(0) else: res = 1 for v in vec: res *= v if(res > 10**18): res = -1 break print(res)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
76
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; ll a[n]; ll m = 1; ll mn = 1e18; for (int i = 0; i < n; i++) { cin >> a[i]; mn = min(mn, a[i]); } if (mn == 0) { cout << 0 << endl; return 0; } for (int i = 0; i < n; i++) { if (1e18...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; ll a[n]; ll m = 1; ll mn = 1e18; for (int i = 0; i < n; i++) { cin >> a[i]; mn = min(mn, a[i]); } if (mn == 0) { cout << 0 << endl; return 0; } for (int i = 0; i < n; i++) { if (1000...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 13]]
1
141