Submission #13785353


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
public:

	void Solve() {
		UL N; cin >> N;
		ULL ans = 1;
		bool over = false;
		rep(i, N) {
			ULL A; cin >> A;
			if (A == 0) { over = false; ans = 0; break; }
			if (1000000000000000000 / A + 1 < ans) { over = true; }
			ans *= A;
		}
		if (over || ans > 1000000000000000000) cout << -1 << endl;
		else cout << ans << endl;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}

Submission Info

Submission Time
Task B - Multiplication 2
User Nachia
Language C++ (GCC 9.2.1)
Score 200
Code Size 630 Byte
Status AC
Exec Time 56 ms
Memory 3632 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, max_01.txt, max_02.txt, random_01.txt, random_02.txt, random_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, small11_02.txt, small11_03.txt, small11_04.txt, small12_02.txt, small12_03.txt, small12_04.txt, small21_01.txt, small21_02.txt, small21_03.txt, small22_01.txt, small22_02.txt, small22_03.txt, zero_01.txt, zero_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 2 ms 3548 KB
hand_02.txt AC 2 ms 3432 KB
max_01.txt AC 56 ms 3492 KB
max_02.txt AC 18 ms 3624 KB
random_01.txt AC 35 ms 3492 KB
random_02.txt AC 33 ms 3628 KB
random_03.txt AC 32 ms 3496 KB
sample_01.txt AC 2 ms 3628 KB
sample_02.txt AC 2 ms 3596 KB
sample_03.txt AC 2 ms 3592 KB
small11_02.txt AC 2 ms 3524 KB
small11_03.txt AC 2 ms 3608 KB
small11_04.txt AC 2 ms 3488 KB
small12_02.txt AC 2 ms 3524 KB
small12_03.txt AC 2 ms 3592 KB
small12_04.txt AC 2 ms 3548 KB
small21_01.txt AC 19 ms 3632 KB
small21_02.txt AC 17 ms 3492 KB
small21_03.txt AC 19 ms 3436 KB
small22_01.txt AC 18 ms 3624 KB
small22_02.txt AC 18 ms 3596 KB
small22_03.txt AC 19 ms 3596 KB
zero_01.txt AC 26 ms 3520 KB
zero_02.txt AC 28 ms 3492 KB