Submission #13826805


Source Code Expand

Copy
#include <iostream>
#include <vector>
using i64 = long long;

int main() {
    constexpr i64 inf = 1000000000000000000;
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;

    for (auto e : a) {
        if (!e) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    i64 ret = 1;
    for (const i64 e : a) {
        if (ret > inf / e) {
            std::cout << -1 << std::endl;
            return 0;
        }
        ret *= e;
    }

    std::cout << ret << std::endl;

    return 0;
}

Submission Info

Submission Time
Task B - Multiplication 2
User CharlotteL
Language C++ (GCC 9.2.1)
Score 200
Code Size 592 Byte
Status AC
Exec Time 52 ms
Memory 4052 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 3 ms 3628 KB
hand_02.txt AC 2 ms 3488 KB
max_01.txt AC 52 ms 3964 KB
max_02.txt AC 24 ms 3824 KB
random_01.txt AC 34 ms 3712 KB
random_02.txt AC 33 ms 3736 KB
random_03.txt AC 35 ms 3736 KB
sample_01.txt AC 2 ms 3600 KB
sample_02.txt AC 2 ms 3552 KB
sample_03.txt AC 2 ms 3524 KB
small11_02.txt AC 2 ms 3492 KB
small11_03.txt AC 2 ms 3412 KB
small11_04.txt AC 2 ms 3492 KB
small12_02.txt AC 3 ms 3572 KB
small12_03.txt AC 2 ms 3596 KB
small12_04.txt AC 2 ms 3416 KB
small21_01.txt AC 18 ms 3896 KB
small21_02.txt AC 19 ms 4052 KB
small21_03.txt AC 20 ms 3960 KB
small22_01.txt AC 19 ms 3988 KB
small22_02.txt AC 18 ms 3868 KB
small22_03.txt AC 21 ms 3812 KB
zero_01.txt AC 52 ms 3964 KB
zero_02.txt AC 51 ms 3960 KB