Submission #13920293


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
ll mul(ll a, ll b) { if (a == 0) return 0; if (infl / a < b) return infl; return min(infl, a * b); }
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N;
ll MA = 1;
//---------------------------------------------------------------------------------------------------
void _main() {
	rep(i, 0, 18) MA *= 10;

	cin >> N;
	ll tot = 1;
	rep(i, 0, N) {
		ll a; cin >> a;
		tot = mul(tot, a);
	}
	if (MA < tot) cout << "-1" << endl;
	else cout << tot << endl;
}





Submission Info

Submission Time
Task B - Multiplication 2
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 200
Code Size 1713 Byte
Status AC
Exec Time 21 ms
Memory 3644 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 5 ms 3544 KB
hand_02.txt AC 2 ms 3576 KB
max_01.txt AC 19 ms 3592 KB
max_02.txt AC 15 ms 3612 KB
random_01.txt AC 15 ms 3548 KB
random_02.txt AC 11 ms 3528 KB
random_03.txt AC 16 ms 3540 KB
sample_01.txt AC 2 ms 3608 KB
sample_02.txt AC 2 ms 3540 KB
sample_03.txt AC 2 ms 3608 KB
small11_02.txt AC 3 ms 3536 KB
small11_03.txt AC 2 ms 3548 KB
small11_04.txt AC 2 ms 3612 KB
small12_02.txt AC 2 ms 3612 KB
small12_03.txt AC 2 ms 3548 KB
small12_04.txt AC 2 ms 3612 KB
small21_01.txt AC 11 ms 3644 KB
small21_02.txt AC 12 ms 3500 KB
small21_03.txt AC 14 ms 3536 KB
small22_01.txt AC 12 ms 3644 KB
small22_02.txt AC 11 ms 3548 KB
small22_03.txt AC 15 ms 3608 KB
zero_01.txt AC 18 ms 3536 KB
zero_02.txt AC 21 ms 3612 KB