結果

問題 No.761 平均値ゲーム
ユーザー t33f
提出日時 2018-12-09 15:58:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 59,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-16 09:00:29
合計ジャッジ時間 5,010 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <map>
#include <iostream>
using namespace std;

long long a[100100], s[100100];

bool check(int i, int j) {
    if (a[i] == a[j]) return true;
    long long sum = s[j+1] - s[i];
    int k = j, lb = i;
    while (k - lb > 1) {
        int m = (k + lb) / 2;
        if (a[m] * (j - i + 1) >= sum) k = m;
        else lb = m;
    }
    return !check(i, k-1) || !check(k, j);
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    s[0] = 0; for (int i = 0; i < n; i++) s[i+1] = s[i] + a[i];
    cout << (check(0, n-1) ? "First" : "Second") << endl;
}
0