結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
30,392 KB
testcase_01 AC 11 ms
30,604 KB
testcase_02 AC 10 ms
30,384 KB
testcase_03 AC 10 ms
30,408 KB
testcase_04 AC 11 ms
30,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 10 ms
30,596 KB
testcase_11 AC 23 ms
30,200 KB
testcase_12 AC 24 ms
30,288 KB
testcase_13 WA -
testcase_14 AC 23 ms
30,336 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 9 ms
30,020 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 8 ms
30,020 KB
testcase_23 AC 9 ms
30,076 KB
testcase_24 AC 9 ms
30,024 KB
testcase_25 AC 9 ms
30,008 KB
testcase_26 AC 9 ms
30,028 KB
testcase_27 AC 9 ms
30,032 KB
testcase_28 WA -
testcase_29 AC 9 ms
30,040 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 53 ms
30,368 KB
testcase_35 AC 52 ms
30,524 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 53 ms
30,500 KB
testcase_39 WA -
testcase_40 AC 9 ms
30,208 KB
testcase_41 AC 9 ms
29,960 KB
testcase_42 AC 9 ms
29,956 KB
testcase_43 WA -
testcase_44 AC 9 ms
29,960 KB
testcase_45 WA -
testcase_46 AC 64 ms
30,448 KB
testcase_47 WA -
testcase_48 AC 64 ms
30,424 KB
testcase_49 WA -
testcase_50 AC 63 ms
30,380 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 34 ms
30,648 KB
testcase_54 AC 34 ms
30,388 KB
testcase_55 AC 34 ms
30,468 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,r){
        if(sum[i+1] > 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