結果
問題 | No.761 平均値ゲーム |
ユーザー |
|
提出日時 | 2018-12-15 16:41:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 1,789 ms |
コンパイル使用メモリ | 170,320 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 06:17:55 |
合計ジャッジ時間 | 5,310 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; bool solve(int L, int R, vector<ll>& a, vector<ll>& sum) { int m = R - L; if (m == 0) return false; if (m == 1) return true; //if (m == 2) return false; //if (m == 3) return true; ll s = sum[R] - sum[L]; int ng = L - 1, ok = R - 1; while (ok - ng > 1) { int mid = (ok + ng) / 2; if (a[mid] * m >= s) ok = mid; else ng = mid; } if (ok == L) return true; return !solve(L, ok, a, sum) || !solve(ok, R, a, sum); } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> a(n), sum(n + 1, 0); for (int i = 0; i < n; i++) { cin >> a[i]; sum[i + 1] = sum[i] + a[i]; } cout << (solve(0, n, a, sum) ? "First" : "Second") << endl; return 0; }