結果

問題 No.973 余興
ユーザー yakkiyakki
提出日時 2020-01-18 10:42:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,258 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 128,688 KB
実行使用メモリ 7,172 KB
最終ジャッジ日時 2023-09-09 10:07:05
合計ジャッジ時間 6,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
7,156 KB
testcase_01 AC 7 ms
6,924 KB
testcase_02 AC 6 ms
6,856 KB
testcase_03 AC 7 ms
6,868 KB
testcase_04 AC 7 ms
7,092 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 7 ms
6,720 KB
testcase_11 AC 22 ms
4,860 KB
testcase_12 AC 22 ms
4,932 KB
testcase_13 WA -
testcase_14 AC 22 ms
4,812 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
4,384 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 62 ms
6,920 KB
testcase_35 AC 62 ms
6,868 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 62 ms
6,880 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,384 KB
testcase_45 WA -
testcase_46 AC 77 ms
6,856 KB
testcase_47 WA -
testcase_48 AC 76 ms
6,920 KB
testcase_49 AC 5 ms
6,224 KB
testcase_50 AC 77 ms
6,884 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 39 ms
6,860 KB
testcase_54 AC 38 ms
7,144 KB
testcase_55 AC 38 ms
7,172 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;
vector<vector<bool>> used;
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);
    used.resize(N,vector<bool>(N,false));
    sum.resize(N+1);
    rep(i,N) cin >> a[i];
    rep(i,N) sum[i+1] = sum[i]+a[i];
    cout << (solve(0,N)?'A':'B') << endl;
}
    

0