結果
問題 | No.761 平均値ゲーム |
ユーザー |
|
提出日時 | 2018-12-10 03:48:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 1,980 ms |
コンパイル使用メモリ | 200,708 KB |
最終ジャッジ日時 | 2025-01-06 18:52:18 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include <bits/stdc++.h>using namespace std;signed main() {ios::sync_with_stdio(false);int N;cin >> N;vector<int64_t> A(N);for (int i = 0; i < N; ++i) cin >> A[i];vector<int64_t> asum(N + 1);partial_sum(A.begin(), A.end(), asum.begin() + 1);function<int(int, int)> solve = [&](int lb, int rb) {if (lb == rb) return 1; // second winsif (A[lb] == A[rb - 1]) return 0;int a = lb, b = rb;while (b - a > 1) {int c = a + b >> 1;(A[c] * (rb - lb) < asum[rb] - asum[lb] ? a : b) = c;}return !solve(lb, a + 1) & !solve(a + 1, rb);};cout << vector<string>({"First", "Second"})[solve(0, N)] << endl;return 0;}