結果

問題 No.1816 MUL-DIV Game
ユーザー Be11T_Be11T_
提出日時 2022-01-21 22:39:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 2,043 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 208,404 KB
実行使用メモリ 8,732 KB
最終ジャッジ日時 2023-08-17 06:58:02
合計ジャッジ時間 4,250 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 27 ms
5,472 KB
testcase_11 AC 24 ms
5,308 KB
testcase_12 AC 18 ms
4,740 KB
testcase_13 AC 37 ms
6,384 KB
testcase_14 AC 20 ms
4,900 KB
testcase_15 AC 26 ms
5,584 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 53 ms
7,544 KB
testcase_18 AC 48 ms
7,176 KB
testcase_19 AC 23 ms
5,188 KB
testcase_20 AC 55 ms
7,764 KB
testcase_21 AC 17 ms
4,848 KB
testcase_22 AC 14 ms
4,608 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 65 ms
8,516 KB
testcase_26 AC 64 ms
8,568 KB
testcase_27 AC 65 ms
8,552 KB
testcase_28 AC 65 ms
8,732 KB
testcase_29 AC 65 ms
8,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, m, n) for(ll i = m; i <= n; i++)
#define rrep(i, m, n) for(ll i = m; i >= n; i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define SZ(a) ((ll)(a).size())
#define bit(n, k) ((n >> k) & 1)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int dx[4] = { -1, 1, 0, 0 };
const int dy[4] = { 0, 0, 1, -1 };
const int inf = 1e9 + 1;
const ll INF = 1e18;
const double pi = acos(-1);

using Graph = vector<vector<ll>>;
using REV_PQ = priority_queue<ll, vector<ll>, greater<ll>>;
using PQ = priority_queue<ll>;

//typedef atcoder::modint998244353 mint;
//typedef atcoder::modint1000000007 mint;

const int SIZE = 200010;

ll powll(ll n, ll x) {
    // return n ^ x;

    ll ret = 1;
    rep(i, x) ret *= n;

    return ret;
}

struct Edge { ll u, v, cost; };

bool comp(const Edge& e1, const Edge& e2) {
    return e1.cost < e2.cost;
}

int target = 0;
int op1(int a, int b) { return max(a, b); }
int e1() { return -1; }
bool f1(int v) { return v < target; }
int op2(int a, int b) { return min(a, b); }
int e2() { return -1; }
bool f2(int v) { return v > target; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    sort(rall(a));
    multiset<ll> se;
    rep(i, n) se.insert(a[i]);

    int i = 0;
    ll x, y;
    while(SZ(se) > 1){
        if(i % 2 == 0){
            auto it = se.begin();
            x = *it;
            se.erase(it);
            it = se.begin();
            y = *it;
            se.erase(it);
            se.insert(x * y);
        }else{
            auto it = se.end();
            it--;
            se.erase(it);
            it = se.end();
            it--;
            se.erase(it);
            se.insert(1);
        }
        i++;
    }
    cout << *se.begin() << endl;
}
0