結果

問題 No.973 余興
ユーザー mkawa2mkawa2
提出日時 2020-01-17 23:04:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 924 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 163,284 KB
実行使用メモリ 56,308 KB
最終ジャッジ日時 2023-09-08 06:42:44
合計ジャッジ時間 10,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
56,308 KB
testcase_01 AC 270 ms
51,936 KB
testcase_02 AC 244 ms
52,124 KB
testcase_03 AC 244 ms
51,976 KB
testcase_04 AC 245 ms
51,904 KB
testcase_05 AC 267 ms
51,852 KB
testcase_06 AC 276 ms
51,892 KB
testcase_07 AC 253 ms
51,912 KB
testcase_08 AC 266 ms
52,140 KB
testcase_09 AC 256 ms
51,828 KB
testcase_10 AC 252 ms
51,044 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 <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int n,x;
int a[5005];
bool dp[5005][5005];
bool done[5005][5005];

bool win(int l,int r){
  if(done[l][r]) return dp[l][r];
  if(l+1==r) return false;
  bool res=false;
  ll s=0;
  for(int nl=l+1;nl<r;nl++){
    s+=a[nl-1];
    if(s>x) break;
    if(win(nl,r)==false){
      res=true;
      break;
    }
  }
  s=0;
  for(int nr=r-1;nr>l;nr--){
    if(res) break;
    s+=a[nr];
    if(s>x) break;
    if(win(l,nr)==false){
      res=true;
      break;
    }
  }
  done[l][r]=true;
  dp[l][r]=res;
  return res;
}

int main() {
  cin>>n>>x;
  rep(i,n) cin>>a[i];
  if(win(0,n)) puts("A");
  else puts("B");
  return 0;
}
0