結果

問題 No.973 余興
ユーザー chocoruskchocorusk
提出日時 2020-01-17 22:15:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,435 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 109,132 KB
実行使用メモリ 301,068 KB
最終ジャッジ日時 2023-09-08 03:44:45
合計ジャッジ時間 10,795 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
290,336 KB
testcase_01 AC 221 ms
300,808 KB
testcase_02 AC 218 ms
300,808 KB
testcase_03 AC 216 ms
300,780 KB
testcase_04 AC 218 ms
300,808 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 213 ms
297,136 KB
testcase_11 AC 97 ms
184,076 KB
testcase_12 AC 96 ms
183,856 KB
testcase_13 WA -
testcase_14 AC 96 ms
183,808 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 16 ms
51,420 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 21 ms
63,908 KB
testcase_23 AC 19 ms
57,628 KB
testcase_24 AC 19 ms
57,724 KB
testcase_25 AC 12 ms
41,132 KB
testcase_26 AC 17 ms
51,392 KB
testcase_27 AC 24 ms
70,016 KB
testcase_28 WA -
testcase_29 AC 19 ms
57,684 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 224 ms
300,772 KB
testcase_35 AC 219 ms
300,788 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 217 ms
300,892 KB
testcase_39 WA -
testcase_40 AC 2 ms
7,716 KB
testcase_41 AC 2 ms
7,468 KB
testcase_42 AC 3 ms
7,508 KB
testcase_43 WA -
testcase_44 AC 2 ms
7,488 KB
testcase_45 WA -
testcase_46 AC 214 ms
300,888 KB
testcase_47 WA -
testcase_48 AC 220 ms
300,864 KB
testcase_49 WA -
testcase_50 AC 217 ms
300,708 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 215 ms
299,220 KB
testcase_54 AC 219 ms
301,068 KB
testcase_55 AC 215 ms
300,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int dp[5050][5050];
int s1[5050][5050];
int s2[5050][5050];
ll a[5050];
ll s[5050];
int n;
ll x;
int solve(int l, int r){
	if(dp[l][r]!=-1) return dp[l][r];
	if(l==r){
		dp[l][r]=1;
		s1[l][r]=s2[l][r]=1;
		return 1;
	}
	solve(l+1, r);
	solve(l, r-1);
	int k=upper_bound(s, s+n+1, s[l]+x)-s;
	k-=2;
	k=min(k, r-1);
	if(s1[l+1][r]-s1[k+2][r]>0){
		dp[l][r]=0;
		s1[l][r]=s1[l+1][r]+dp[l][r];
		s2[l][r]=s2[l][r-1]+dp[l][r];
		return dp[l][r];
	}
	k=lower_bound(s, s+n+1, s[r+1]-x)-s;
	k=max(k, l+1);
	if(s2[l][r-1]-s2[l][k-2]>0){
		dp[l][r]=0;
	}else{
		dp[l][r]=1;
	}
	s1[l][r]=s1[l+1][r]+dp[l][r];
	s2[l][r]=s2[l][r-1]+dp[l][r];
	return dp[l][r];
}
int main()
{
	int n;
	ll x;
	cin>>n>>x;
	for(int i=0; i<n; i++){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}
	for(int i=0; i<n; i++) for(int j=i; j<n; j++) dp[i][j]=-1;
	solve(0, n-1);
	if(dp[0][n-1]) cout<<"B"<<endl;
	else cout<<"A"<<endl;
	return 0;
}
0