結果

問題 No.973 余興
ユーザー yakkiyakki
提出日時 2020-01-22 20:52:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,242 bytes
コンパイル時間 1,062 ms
コンパイル使用メモリ 119,584 KB
実行使用メモリ 107,784 KB
最終ジャッジ日時 2023-09-23 00:32:01
合計ジャッジ時間 12,755 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 339 ms
107,784 KB
testcase_01 AC 343 ms
103,372 KB
testcase_02 AC 344 ms
103,380 KB
testcase_03 AC 342 ms
103,456 KB
testcase_04 AC 347 ms
103,376 KB
testcase_05 AC 335 ms
103,368 KB
testcase_06 AC 348 ms
103,364 KB
testcase_07 AC 343 ms
103,428 KB
testcase_08 AC 338 ms
103,380 KB
testcase_09 AC 351 ms
103,412 KB
testcase_10 AC 325 ms
103,372 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

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>
#include<cstdio>
#include<cstdlib>
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

const double EPS = 1e-10;

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

int N,X; 
vector<int> a;

int dp[5050][5050];

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

int main(){
    cin >> N >> X;
    a.resize(N);
    rep(i,N) cin >> a[i];

    rep(i,5050)rep(j,5050) dp[i][j] = -1;
    cout << (solve(0,N)?'A':'B') << endl;
}
0