結果

問題 No.973 余興
ユーザー ransewhaleransewhale
提出日時 2020-01-17 22:57:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,155 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 165,820 KB
実行使用メモリ 124,148 KB
最終ジャッジ日時 2023-09-08 06:26:18
合計ジャッジ時間 20,276 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 50 ms
123,932 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 56 ms
123,956 KB
testcase_22 WA -
testcase_23 AC 50 ms
123,928 KB
testcase_24 AC 50 ms
124,140 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 61 ms
123,932 KB
testcase_28 WA -
testcase_29 AC 51 ms
123,864 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 35 ms
124,032 KB
testcase_41 AC 34 ms
123,856 KB
testcase_42 AC 33 ms
124,032 KB
testcase_43 WA -
testcase_44 AC 33 ms
123,904 KB
testcase_45 AC 33 ms
123,908 KB
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
権限があれば一括ダウンロードができます

ソースコード

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(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]]<=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]-1] - 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