結果
| 問題 | No.1816 MUL-DIV Game |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-01-29 12:50:58 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 912 bytes |
| 記録 | |
| コンパイル時間 | 300 ms |
| コンパイル使用メモリ | 63,360 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2026-06-05 16:25:51 |
| 合計ジャッジ時間 | 2,831 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1816.cc: No.1816 MUL-DIV Game - yukicoder
*/
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
typedef long long ll;
typedef multiset<ll> msl;
/* global variables */
msl as;
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int ai;
scanf("%d", &ai);
as.insert(ai);
}
while (as.size() > 1) {
// Alice
{
msl::iterator mit = as.begin();
ll a0 = *(mit++), a1 = *(mit++);
as.erase(as.begin(), mit);
as.insert(a0 * a1);
if (as.size() == 1) break;
}
// Bob
{
msl::iterator mit = as.end();
ll a0 = *(--mit), a1 = *(--mit);
as.erase(mit, as.end());
as.insert(1);
if (as.size() == 1) break;
}
}
printf("%lld\n", *as.begin());
return 0;
}
tnakao0123