結果

問題 No.973 余興
ユーザー ransewhaleransewhale
提出日時 2020-01-17 23:04:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,186 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 165,184 KB
実行使用メモリ 124,192 KB
最終ジャッジ日時 2023-09-08 06:38:58
合計ジャッジ時間 17,241 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 443 ms
124,184 KB
testcase_01 AC 439 ms
123,928 KB
testcase_02 AC 438 ms
123,876 KB
testcase_03 WA -
testcase_04 AC 441 ms
123,940 KB
testcase_05 AC 446 ms
123,984 KB
testcase_06 WA -
testcase_07 AC 447 ms
123,876 KB
testcase_08 AC 441 ms
123,908 KB
testcase_09 AC 449 ms
123,988 KB
testcase_10 AC 423 ms
123,940 KB
testcase_11 AC 140 ms
123,968 KB
testcase_12 AC 141 ms
123,928 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 43 ms
123,972 KB
testcase_16 WA -
testcase_17 AC 40 ms
123,880 KB
testcase_18 AC 41 ms
123,920 KB
testcase_19 AC 42 ms
123,980 KB
testcase_20 AC 40 ms
124,104 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 41 ms
123,852 KB
testcase_24 AC 41 ms
123,960 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 42 ms
124,008 KB
testcase_30 AC 344 ms
123,944 KB
testcase_31 AC 344 ms
123,896 KB
testcase_32 AC 346 ms
124,192 KB
testcase_33 AC 345 ms
124,152 KB
testcase_34 AC 343 ms
124,136 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 343 ms
123,944 KB
testcase_39 WA -
testcase_40 AC 34 ms
123,888 KB
testcase_41 AC 33 ms
123,908 KB
testcase_42 AC 34 ms
123,952 KB
testcase_43 WA -
testcase_44 AC 33 ms
124,152 KB
testcase_45 AC 34 ms
123,908 KB
testcase_46 AC 340 ms
123,944 KB
testcase_47 AC 341 ms
123,888 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 338 ms
123,984 KB
testcase_51 AC 341 ms
123,944 KB
testcase_52 AC 341 ms
123,948 KB
testcase_53 WA -
testcase_54 AC 339 ms
123,944 KB
testcase_55 AC 339 ms
123,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int dp[5555][5555];
ll s[5555];

int main(void){
	int i,j,n;
	ll a,x;
	cin >> n >> x;
	fill(dp[0],dp[5555],-1);
	for(i=0; i<n; ++i){
		cin >> a;
		s[i+1] = s[i]+a;
	}
	for(i=1; i<n; ++i){
		for(j=0; j<n; ++j){
			if(j+i>n){
				break;
			}
			if(dp[j][j+i]<0 && dp[j+i][j]<0){
				dp[j][j+i+1] = max(j+i,dp[j][j+i+1]);
				if(j){
					if(dp[j+i][j-1]<0){
						dp[j+i][j-1] = j;
					}else{
						dp[j+i][j-1] = min(j,dp[j+i][j-1]);
					}
				}
			}
			if(!(dp[j][j+i]<0)){
				if(s[j+i+1]-s[dp[j][j+i]+1]<=x){
					dp[j][j+i+1] = max(dp[j][j+i+1],dp[j][j+i]);
				}
			}
			if(!(dp[j+i][j]<0) && j){
				if(s[dp[j+i][j]] - s[j-1] <= x){
					if(dp[j+i][j-1]<0){
						dp[j+i][j-1] = dp[j+i][j];
					}else{
						dp[j+i][j-1] = min(dp[j+i][j-1],dp[j+i][j]);
					}
				}
			}
		}
	}
	cout << ((dp[0][n]<0 && dp[n][0]<0)?"B":"A") << endl;
	return 0;
}
0