Submission #13804603


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;

    ll a[n];
    rep(i,n)cin >> a[i];

    rep(i,n){
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;

    ll INF = 3001001001001001001;

    rep(i,n){
        if(INF/ans < a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    if(ans > 1000000000000000000){
        ans = -1;
    }
    
    cout << ans << endl;
    return 0;
}


Submission Info

Submission Time
Task B - Multiplication 2
User Shibuyap
Language C++ (GCC 9.2.1)
Score 200
Code Size 829 Byte
Status AC
Exec Time 53 ms
Memory 4416 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 3584 KB
hand_02.txt AC 4 ms 3632 KB
max_01.txt AC 51 ms 4172 KB
max_02.txt AC 20 ms 4416 KB
random_01.txt AC 34 ms 4024 KB
random_02.txt AC 33 ms 3968 KB
random_03.txt AC 34 ms 3824 KB
sample_01.txt AC 4 ms 3568 KB
sample_02.txt AC 2 ms 3548 KB
sample_03.txt AC 6 ms 3524 KB
small11_02.txt AC 2 ms 3432 KB
small11_03.txt AC 2 ms 3436 KB
small11_04.txt AC 2 ms 3636 KB
small12_02.txt AC 2 ms 3448 KB
small12_03.txt AC 2 ms 3444 KB
small12_04.txt AC 2 ms 3440 KB
small21_01.txt AC 18 ms 4220 KB
small21_02.txt AC 20 ms 4304 KB
small21_03.txt AC 20 ms 4232 KB
small22_01.txt AC 20 ms 4328 KB
small22_02.txt AC 23 ms 4352 KB
small22_03.txt AC 20 ms 4300 KB
zero_01.txt AC 53 ms 4216 KB
zero_02.txt AC 53 ms 4308 KB