結果
問題 |
No.1817 Reversed Edges
|
ユーザー |
![]() |
提出日時 | 2022-01-21 22:59:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 995 bytes |
コンパイル時間 | 9,002 ms |
コンパイル使用メモリ | 404,708 KB |
最終ジャッジ日時 | 2025-01-27 14:20:55 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 23 |
ソースコード
#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; }