結果

問題 No.973 余興
ユーザー face4face4
提出日時 2020-01-17 23:21:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 79,324 KB
実行使用メモリ 10,024 KB
最終ジャッジ日時 2023-09-08 07:33:26
合計ジャッジ時間 39,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,312 ms
9,664 KB
testcase_02 WA -
testcase_03 AC 1,351 ms
9,732 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,323 ms
9,636 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,303 ms
9,468 KB
testcase_11 AC 406 ms
5,852 KB
testcase_12 AC 398 ms
5,860 KB
testcase_13 AC 395 ms
5,868 KB
testcase_14 WA -
testcase_15 AC 53 ms
4,384 KB
testcase_16 WA -
testcase_17 AC 33 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 41 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 51 ms
4,380 KB
testcase_23 AC 39 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 18 ms
4,384 KB
testcase_26 AC 31 ms
4,380 KB
testcase_27 AC 60 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 40 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,053 ms
9,724 KB
testcase_39 AC 1,055 ms
9,652 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 315 ms
9,108 KB
testcase_50 AC 367 ms
9,632 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 1,291 ms
9,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 取れるだけ取ってしまう
// コーナーケースがあると思います
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, x;
    cin >> n >> x;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    vector<ll> sum = v;
    for(int i = 1; i < n; i++) sum[i] += sum[i-1];
    vector<vector<bool>> avail(n, vector<bool>(n, 0));
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            avail[i][j] = (sum[j]-(i==0 ? 0 : sum[i-1])) <= x;
        }
    }
    vector<vector<bool>> win(n, vector<bool>(n, 0));
    for(int w = 2; w <= n; w++){
        for(int i = 0; i+w-1 < n; i++){
            int j = i+w-1;  // [i, j]
            int k = --upper_bound(sum.begin(), sum.end(), (i==0 ? 0 : sum[i-1])+x)-sum.begin();
            if(k >= j-1){
                win[i][j] = true;
            }else{
                win[i][j] = !win[k+1][j];
            }
            k = lower_bound(sum.begin(),sum.end(),sum[j]-x)-sum.begin();
            if(k <= i+1){
                win[i][j] = true;
            }else{
                win[i][j] = win[i][j] | !win[i][k-1];
            }
        }
    }
    cout << "BA"[win[0][n-1]] << endl;
    return 0;
}
0