結果

問題 No.1816 MUL-DIV Game
ユーザー horoyoisawahoroyoisawa
提出日時 2022-01-21 22:11:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 168,828 KB
実行使用メモリ 8,084 KB
最終ジャッジ日時 2023-08-17 06:16:53
合計ジャッジ時間 4,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 34 ms
5,380 KB
testcase_11 AC 30 ms
5,376 KB
testcase_12 AC 22 ms
4,708 KB
testcase_13 AC 48 ms
6,304 KB
testcase_14 AC 26 ms
5,000 KB
testcase_15 AC 35 ms
5,428 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 69 ms
7,220 KB
testcase_18 AC 70 ms
6,936 KB
testcase_19 AC 31 ms
5,164 KB
testcase_20 AC 78 ms
7,484 KB
testcase_21 AC 23 ms
4,856 KB
testcase_22 AC 17 ms
4,460 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 96 ms
8,064 KB
testcase_26 AC 96 ms
8,016 KB
testcase_27 AC 93 ms
8,048 KB
testcase_28 AC 90 ms
8,084 KB
testcase_29 AC 92 ms
8,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    multiset<long long> st;
    for(int i=0;i<n;i++) {
        int a;
        cin >> a;
        st.insert(a);
    }
    for(int i=0;i<n-1;i++) {
        long long alpha, beta, gamma;
        if(i % 2 == 0) {
            auto it = st.begin();
            alpha = *it;
            st.erase(it);
            it = st.begin();
            beta = *it;
            st.erase(it);
            gamma = alpha * beta;
        }
        else {
            auto it = st.end();
            it--;
            st.erase(it);
            it = st.end();
            it--;
            st.erase(it);
            gamma = 1;
        }
        st.insert(gamma);
    }


    cout << *st.begin() << '\n';

    return 0;
}
0