結果

問題 No.973 余興
ユーザー otamay6otamay6
提出日時 2020-01-19 12:21:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,027 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 169,120 KB
実行使用メモリ 101,020 KB
最終ジャッジ日時 2023-09-15 19:58:37
合計ジャッジ時間 18,795 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 616 ms
100,920 KB
testcase_01 AC 613 ms
101,008 KB
testcase_02 AC 615 ms
100,956 KB
testcase_03 AC 619 ms
100,672 KB
testcase_04 AC 614 ms
101,004 KB
testcase_05 AC 617 ms
101,008 KB
testcase_06 AC 617 ms
100,976 KB
testcase_07 AC 619 ms
100,748 KB
testcase_08 AC 613 ms
100,592 KB
testcase_09 AC 613 ms
100,992 KB
testcase_10 AC 586 ms
96,920 KB
testcase_11 AC 102 ms
38,432 KB
testcase_12 AC 100 ms
38,500 KB
testcase_13 AC 101 ms
38,052 KB
testcase_14 AC 100 ms
38,128 KB
testcase_15 AC 19 ms
7,472 KB
testcase_16 AC 19 ms
7,304 KB
testcase_17 AC 12 ms
5,724 KB
testcase_18 AC 16 ms
6,588 KB
testcase_19 AC 15 ms
6,640 KB
testcase_20 WA -
testcase_21 AC 19 ms
7,192 KB
testcase_22 AC 19 ms
7,284 KB
testcase_23 AC 15 ms
6,576 KB
testcase_24 WA -
testcase_25 AC 8 ms
4,748 KB
testcase_26 AC 12 ms
5,708 KB
testcase_27 AC 21 ms
7,552 KB
testcase_28 AC 16 ms
6,592 KB
testcase_29 AC 15 ms
6,368 KB
testcase_30 AC 368 ms
100,964 KB
testcase_31 AC 373 ms
100,956 KB
testcase_32 AC 367 ms
100,960 KB
testcase_33 AC 369 ms
100,744 KB
testcase_34 AC 367 ms
100,360 KB
testcase_35 AC 368 ms
100,824 KB
testcase_36 AC 356 ms
98,228 KB
testcase_37 AC 355 ms
98,376 KB
testcase_38 AC 369 ms
100,860 KB
testcase_39 AC 368 ms
100,748 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 367 ms
101,020 KB
testcase_47 AC 369 ms
100,940 KB
testcase_48 AC 371 ms
101,012 KB
testcase_49 AC 338 ms
93,264 KB
testcase_50 AC 367 ms
100,188 KB
testcase_51 AC 369 ms
101,008 KB
testcase_52 AC 366 ms
100,828 KB
testcase_53 AC 358 ms
99,040 KB
testcase_54 AC 365 ms
101,016 KB
testcase_55 AC 367 ms
100,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
 template<typename T>
    bool chmin(T &a,T b){
        if(b<a){
            a=b;
            return true;
        }
        return false;
    }
int main(){
    int N,X;cin>>N>>X;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<vector<int>> win(N,vector<int>(N,X+1));
    REP(i,N) win[i][i]=X+1;
    rep(k,1,N) REP(i,N){
        if(i-k>=0){
            int res=win[i-k+1][i]+a[i-k];
            if(res-a[i-k]==X+1) chmin(win[i-k][i],a[i-k]);
            else if(res<=X) chmin(win[i-k][i],res);
        }
        if(i+k<N){
            int res=win[i][i+k-1]+a[i+k];
            if(res-a[i+k]==X+1) chmin(win[i][i+k],a[i+k]);
            else if(res<=X) chmin(win[i][i+k],res);
        }
    }
    if(win[0][N-1]==X+1) cout<<"B"<<endl;
    else cout<<"A"<<endl;
}
0