結果

問題 No.973 余興
ユーザー yakkiyakki
提出日時 2020-01-18 11:31:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 122,648 KB
実行使用メモリ 30,708 KB
最終ジャッジ日時 2023-09-09 11:27:58
合計ジャッジ時間 5,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 12 ms
30,492 KB
testcase_02 WA -
testcase_03 AC 12 ms
30,424 KB
testcase_04 AC 11 ms
30,380 KB
testcase_05 AC 11 ms
30,424 KB
testcase_06 WA -
testcase_07 AC 11 ms
30,508 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 37 ms
30,216 KB
testcase_12 WA -
testcase_13 AC 37 ms
30,188 KB
testcase_14 AC 37 ms
30,228 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 9 ms
30,012 KB
testcase_20 AC 9 ms
30,056 KB
testcase_21 WA -
testcase_22 AC 9 ms
30,328 KB
testcase_23 AC 9 ms
30,072 KB
testcase_24 AC 9 ms
30,016 KB
testcase_25 AC 9 ms
29,984 KB
testcase_26 AC 8 ms
29,996 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 8 ms
30,076 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 94 ms
30,428 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 93 ms
30,376 KB
testcase_40 AC 9 ms
30,088 KB
testcase_41 AC 9 ms
29,940 KB
testcase_42 AC 9 ms
29,988 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 116 ms
30,396 KB
testcase_47 AC 116 ms
30,404 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 114 ms
30,428 KB
testcase_51 AC 115 ms
30,400 KB
testcase_52 AC 58 ms
30,492 KB
testcase_53 WA -
testcase_54 AC 58 ms
30,380 KB
testcase_55 AC 58 ms
30,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

bool dp[5020][5020];
int N,X;
vector<int> a;
bool used[5020][5020];
vector<ll> sum;

bool solve(int l,int r){
    if(used[l][r]) return dp[l][r];
    used[l][r] = true;
    if(r-l == 1) return dp[l][r] = false;

    bool res = false;
    repr(i,l+1,r){
        if(sum[i] > X) break;
        if(!solve(i,r)) res = true;
    }
    for(int i = r-1; i >= l+1; i--){
        if(sum[r]-sum[i] > X) break;
        if(!solve(l,i)) res = true;
    }
    return dp[l][r] = res;
}

int main(){
    cin >> N >> X;
    a.resize(N);
    sum.resize(N+1);
    rep(i,5020)rep(j,5020) used[i][j] = false;
    rep(i,N) cin >> a[i];
    rep(i,N) sum[i+1] = sum[i]+a[i];
    cout << (solve(0,N)?'A':'B') << endl;
}
    

0