結果

問題 No.973 余興
ユーザー 沙耶花沙耶花
提出日時 2019-12-06 09:10:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,150 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 174,392 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-05-10 01:59:42
合計ジャッジ時間 24,226 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 250 ms
12,352 KB
testcase_01 AC 252 ms
6,716 KB
testcase_02 AC 249 ms
6,848 KB
testcase_03 AC 252 ms
6,784 KB
testcase_04 AC 256 ms
6,912 KB
testcase_05 AC 251 ms
6,716 KB
testcase_06 AC 257 ms
6,784 KB
testcase_07 AC 259 ms
6,716 KB
testcase_08 AC 255 ms
6,784 KB
testcase_09 AC 258 ms
6,844 KB
testcase_10 AC 245 ms
6,656 KB
testcase_11 AC 3,175 ms
5,376 KB
testcase_12 AC 3,170 ms
5,376 KB
testcase_13 AC 3,143 ms
5,376 KB
testcase_14 AC 3,152 ms
5,376 KB
testcase_15 AC 12 ms
5,376 KB
testcase_16 AC 12 ms
5,376 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 8 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 12 ms
5,376 KB
testcase_23 AC 11 ms
5,376 KB
testcase_24 AC 10 ms
5,376 KB
testcase_25 AC 6 ms
5,376 KB
testcase_26 AC 8 ms
5,376 KB
testcase_27 AC 14 ms
5,376 KB
testcase_28 AC 10 ms
5,376 KB
testcase_29 AC 10 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,false));
	
	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;
			int m = min(i,left[l]);
			for(int k=0;k<m;k++){
				if(!dp[l+k+1][r]){
					f=true;
					break;
				}
			}
			if(!f){
			    m = min(i,right[r]);
				for(int k=0;k<m;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