結果

問題 No.1816 MUL-DIV Game
ユーザー keijakkeijak
提出日時 2022-01-21 23:01:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 9,856 ms
コンパイル使用メモリ 446,296 KB
実行使用メモリ 14,196 KB
最終ジャッジ日時 2023-08-17 07:30:05
合計ジャッジ時間 11,849 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 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,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 45 ms
7,908 KB
testcase_11 AC 39 ms
7,340 KB
testcase_12 AC 30 ms
6,300 KB
testcase_13 AC 62 ms
9,712 KB
testcase_14 AC 34 ms
6,824 KB
testcase_15 AC 46 ms
7,860 KB
testcase_16 AC 11 ms
4,380 KB
testcase_17 AC 88 ms
12,140 KB
testcase_18 AC 94 ms
11,684 KB
testcase_19 AC 42 ms
7,416 KB
testcase_20 AC 106 ms
12,540 KB
testcase_21 AC 32 ms
6,280 KB
testcase_22 AC 24 ms
5,812 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 132 ms
14,128 KB
testcase_26 AC 133 ms
14,008 KB
testcase_27 AC 132 ms
14,148 KB
testcase_28 AC 131 ms
14,196 KB
testcase_29 AC 128 ms
14,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <boost/multiprecision/cpp_int.hpp>
using Int = boost::multiprecision::cpp_int;

int main() {
  int n; cin>>n;
  vector<Int> a(n);
  for (auto& x : a) {
      cin>>x;
  }
  multiset<Int> ms(a.begin(), a.end());
  for (int i = 0; i < n-1; ++i) {
      assert(ms.size() >= 2);
      if (i & 1) {
          // Bob's turn
          auto x1 = *prev(ms.end());
          ms.erase(prev(ms.end()));
          auto x2 = *prev(ms.end());
          ms.erase(prev(ms.end()));
          ms.insert((x2 + x1 - 1)/x1);
      } else {
          // Alice's turn
          auto xl = *ms.begin();
          ms.erase(ms.begin());
          if (xl > 1) {
            auto xr = *ms.begin();
            ms.erase(ms.begin());
            ms.insert(xl*xr);
          } else {
            auto xr = *prev(ms.end());
            ms.erase(prev(ms.end()));
            ms.insert(xl*xr);
          }
      }
  }
  assert(ms.size() == 1);
  cout << *ms.begin() << endl;
}
0