結果

問題 No.973 余興
ユーザー 沙耶花沙耶花
提出日時 2019-12-06 08:48:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 1,664 ms
コンパイル使用メモリ 173,780 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-05-10 01:57:43
合計ジャッジ時間 19,461 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 94 ms
6,784 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 92 ms
6,656 KB
testcase_05 WA -
testcase_06 AC 94 ms
6,784 KB
testcase_07 WA -
testcase_08 AC 94 ms
6,784 KB
testcase_09 AC 92 ms
6,848 KB
testcase_10 WA -
testcase_11 AC 2,649 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2,633 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 5 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 4 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 TLE -
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 modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N,X;
	cin>>N>>X;
	
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	
	vector<int> left(N),right(N);
	
	int l = 0;
	int r = 0;
	int sum = 0;
	
	while(true){
		while(r != N && sum + a[r] <= X){
			sum += a[r];
			r++;
		}
		left[l] = r-l;
		sum -= a[l];
		l++;
		if(l==N)break;
	}
	
	l=N-1;
	r=N-1;
	sum=0;
	
	while(true){
		while(l!=-1&&sum+a[l]<=X){
			sum += a[l];
			l--;
		}
		right[r] = r-l;
		sum -= a[r];
		r--;
		if(r<0)break;
	}
	
	vector<vector<bool>> dp(N,vector<bool> (N,true));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			l = j;
			r = j+i;
			if(r>=N)break;
			bool f = false;
			for(int k=0;k<min(r-l,left[j]);k++){
				if(!dp[l+k+1][r]){
					f=true;
					break;
				}
			}
			if(f==false){
				for(int k=0;k>min(r-l,right[j]);k++){
					if(!dp[l][r-k-1]){
						f=true;
						break;
					}
				}
			}
			dp[j][j+i]=f;
		}		
	}

	
	if(!dp[0][N-1]){
		cout<<"B"<<endl;
	}
	else{
		cout<<"A"<<endl;
	}
	
	


	return 0;
}
0