結果

問題 No.761 平均値ゲーム
コンテスト
ユーザー Manuel1024
提出日時 2023-08-15 23:32:03
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 35 ms / 2,000 ms
+ 184µs
コード長 805 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 352 ms
コンパイル使用メモリ 90,404 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-09-29 02:45:22
合計ジャッジ時間 8,028 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

bool f(const vector<ll> &a, const vector<ll> &tot, int l, int r){
    if(r-l <= 0) return false;
    // cerr << l << " " << r << ", ";

    ll ave = tot[r]-tot[l];
    int ac = r, wa = l-1;
    while(ac-wa > 1){
        int wj = (ac+wa)/2;
        if(ave <= a[wj]*(r-l)) ac = wj;
        else wa = wj;
    }

    if(ac == l) return true;

    if(!f(a, tot, ac, r)) return true;
    if(!f(a, tot, l, ac)) return true;
    return false;
}

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    for(auto &it: a) cin >> it;

    vector<ll> tot(n+1, 0);
    for(int i = 0; i < n; i++) tot[i+1] = tot[i]+a[i];

    cout << (f(a, tot, 0, n) ? "First" : "Second") << endl;
    return 0;
}
0