結果

問題 No.973 余興
ユーザー leaf_1415leaf_1415
提出日時 2020-01-18 03:44:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,256 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 60,836 KB
実行使用メモリ 294,356 KB
最終ジャッジ日時 2023-09-08 14:52:44
合計ジャッジ時間 32,713 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 996 ms
292,344 KB
testcase_01 AC 986 ms
294,356 KB
testcase_02 AC 989 ms
293,268 KB
testcase_03 AC 987 ms
293,028 KB
testcase_04 AC 1,007 ms
293,144 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 945 ms
287,392 KB
testcase_11 AC 328 ms
155,468 KB
testcase_12 AC 329 ms
154,424 KB
testcase_13 WA -
testcase_14 AC 326 ms
154,056 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 32 ms
41,744 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 48 ms
52,332 KB
testcase_23 AC 39 ms
47,060 KB
testcase_24 AC 39 ms
46,916 KB
testcase_25 AC 21 ms
33,788 KB
testcase_26 AC 31 ms
41,704 KB
testcase_27 AC 55 ms
57,284 KB
testcase_28 WA -
testcase_29 AC 39 ms
47,076 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 881 ms
292,480 KB
testcase_35 AC 872 ms
293,332 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 888 ms
292,648 KB
testcase_39 WA -
testcase_40 AC 2 ms
5,416 KB
testcase_41 AC 2 ms
5,552 KB
testcase_42 AC 2 ms
5,428 KB
testcase_43 WA -
testcase_44 AC 2 ms
5,648 KB
testcase_45 WA -
testcase_46 AC 510 ms
293,168 KB
testcase_47 WA -
testcase_48 AC 526 ms
293,064 KB
testcase_49 WA -
testcase_50 AC 527 ms
292,988 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 975 ms
290,828 KB
testcase_54 AC 988 ms
293,388 KB
testcase_55 AC 987 ms
294,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

llint n, x;
llint a[5005], sum[5005];;
llint dp[5005][5005], dpsum[5005][5005];

llint get(llint sl, llint sr, llint tl, llint tr)
{
	return dpsum[tl][tr] - dpsum[tl][sr-1] - dpsum[sl+1][tr] + dpsum[sl+1][sr-1];
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	
	for(int l = n; l >= 1; l--){
		for(int r = 1; r <= n; r++){
			if(r-l < 0) continue;
			llint res = 0;
			llint p = upper_bound(sum, sum+n+1, sum[l-1]+x) - sum;
			if(p > r) res++;
			else res += get(l+1, r, p-1, r);
			
			//cout << l << " " << r << " " << p << endl;
			
			p = lower_bound(sum, sum+n+1, sum[r]-x) - sum;
			if(p < l) res++;
			else res += get(l, p+1, l, r);
			
			//cout << l << " " << r << " " << p << endl;
			
			if(res > 0) dp[l][r] = 0;
			else dp[l][r] = 1;
			dpsum[l][r] = dpsum[l+1][r] + dpsum[l][r-1] - dpsum[l+1][r-1] + dp[l][r];
		}
	}
	
	/*for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cout <<dp[i][j]<< " ";
		}
		cout << endl;
	}*/
	
	if(dp[1][n]) cout << "A" << endl;
	else cout << "B" << endl;
	
	return 0;
}
0