結果

問題 No.1816 MUL-DIV Game
ユーザー ktr216ktr216
提出日時 2022-01-21 21:49:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 1,422 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 172,840 KB
実行使用メモリ 13,052 KB
最終ジャッジ日時 2023-08-17 05:38:17
合計ジャッジ時間 4,613 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 11 ms
4,376 KB
testcase_10 AC 56 ms
7,508 KB
testcase_11 AC 49 ms
7,036 KB
testcase_12 AC 36 ms
6,084 KB
testcase_13 AC 86 ms
9,180 KB
testcase_14 AC 42 ms
6,488 KB
testcase_15 AC 58 ms
7,592 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 129 ms
11,544 KB
testcase_18 AC 119 ms
10,908 KB
testcase_19 AC 51 ms
7,160 KB
testcase_20 AC 133 ms
11,940 KB
testcase_21 AC 36 ms
6,176 KB
testcase_22 AC 27 ms
5,472 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 168 ms
13,012 KB
testcase_26 AC 168 ms
13,020 KB
testcase_27 AC 168 ms
13,052 KB
testcase_28 AC 165 ms
13,012 KB
testcase_29 AC 167 ms
12,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using VI = vector<int>;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define ALL(a) (a).begin(),(a).end()

constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr int DX[] = {1, 0, -1, 0};
constexpr int DY[] = {0, 1, 0, -1};

template< typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true); }
template< typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true); }

const ll MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector <ll> A(N);
    multiset<ll> s, t;
    REP(i, N) {
        cin >> A[i];
        s.insert(A[i]);
        t.insert(-A[i]);
    }
    REP(i, N - 1) {
        if (i % 2) {
            ll x = -*t.begin();
            s.erase(s.find(x));
            t.erase(t.find(-x));
            ll y = -*t.begin();
            s.erase(s.find(y));
            t.erase(t.find(-y));
            s.insert(1);
            t.insert(-1);
        } else {
            ll x = *s.begin();
            s.erase(s.find(x));
            t.erase(t.find(-x));
            ll y = *s.begin();
            s.erase(s.find(y));
            t.erase(t.find(-y));
            s.insert(x * y);
            t.insert(-x * y);
        }
    }
    cout << *s.begin() << endl;
}
0