結果

問題 No.973 余興
ユーザー 👑 kmjpkmjp
提出日時 2020-01-18 01:59:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 951 ms / 4,000 ms
コード長 1,387 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 166,392 KB
実行使用メモリ 217,008 KB
最終ジャッジ日時 2023-09-08 12:21:06
合計ジャッジ時間 30,410 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 659 ms
216,756 KB
testcase_01 AC 655 ms
217,008 KB
testcase_02 AC 663 ms
216,800 KB
testcase_03 AC 659 ms
216,720 KB
testcase_04 AC 660 ms
216,816 KB
testcase_05 AC 663 ms
217,004 KB
testcase_06 AC 656 ms
216,800 KB
testcase_07 AC 669 ms
216,672 KB
testcase_08 AC 656 ms
216,400 KB
testcase_09 AC 664 ms
216,744 KB
testcase_10 AC 643 ms
212,356 KB
testcase_11 AC 278 ms
141,588 KB
testcase_12 AC 277 ms
141,884 KB
testcase_13 AC 273 ms
141,176 KB
testcase_14 AC 275 ms
141,556 KB
testcase_15 AC 27 ms
65,584 KB
testcase_16 AC 28 ms
67,716 KB
testcase_17 AC 18 ms
53,340 KB
testcase_18 AC 23 ms
59,452 KB
testcase_19 AC 23 ms
59,468 KB
testcase_20 AC 19 ms
53,248 KB
testcase_21 AC 27 ms
65,660 KB
testcase_22 AC 27 ms
65,576 KB
testcase_23 AC 23 ms
59,488 KB
testcase_24 AC 23 ms
59,528 KB
testcase_25 AC 13 ms
42,856 KB
testcase_26 AC 19 ms
53,412 KB
testcase_27 AC 31 ms
71,780 KB
testcase_28 AC 23 ms
59,612 KB
testcase_29 AC 23 ms
59,372 KB
testcase_30 AC 936 ms
216,700 KB
testcase_31 AC 938 ms
217,008 KB
testcase_32 AC 938 ms
216,820 KB
testcase_33 AC 929 ms
216,888 KB
testcase_34 AC 935 ms
216,176 KB
testcase_35 AC 931 ms
216,740 KB
testcase_36 AC 926 ms
213,964 KB
testcase_37 AC 915 ms
213,900 KB
testcase_38 AC 939 ms
216,608 KB
testcase_39 AC 939 ms
216,628 KB
testcase_40 AC 2 ms
7,416 KB
testcase_41 AC 2 ms
7,592 KB
testcase_42 AC 2 ms
7,424 KB
testcase_43 AC 2 ms
7,604 KB
testcase_44 AC 2 ms
7,576 KB
testcase_45 AC 4 ms
14,112 KB
testcase_46 AC 777 ms
216,824 KB
testcase_47 AC 775 ms
216,608 KB
testcase_48 AC 780 ms
217,008 KB
testcase_49 AC 714 ms
207,720 KB
testcase_50 AC 764 ms
216,036 KB
testcase_51 AC 762 ms
216,812 KB
testcase_52 AC 951 ms
216,880 KB
testcase_53 AC 928 ms
214,740 KB
testcase_54 AC 939 ms
216,696 KB
testcase_55 AC 942 ms
216,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
ll X,A[5050];
int memo[5050][5050];
int L[5050],R[5050];
int Rs[5050][5050];
int Ls[5050][5050];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	FOR(i,N) cin>>A[i];
	
	FOR(i,N+1) {
		L[i]=R[i]=i;
		ll sum=0;
		for(j=i;j<N;j++) {
			sum+=A[j];
			if(sum<=X) R[i]=j+1;
		}
		sum=0;
		
		for(j=i-1;j>=0;j--) {
			sum+=A[j];
			if(sum<=X) L[i]=j;
		}
	}
	FOR(i,N) Ls[i][i+1]=Rs[i][i+1]=1;
	
	for(int len=2;len<=N;len++) {
		for(x=0;x+len<=N;x++) {
			y=Rs[x+1][x+len]-Rs[R[x]+1][x+len];
			y+=Ls[x][x+len-1]-Ls[x][L[x+len]-1];
			memo[x][x+len]=y>0;
			Ls[x][x+len]=Ls[x][x+len-1]+(y==0);
			Rs[x][x+len]=Rs[x+1][x+len]+(y==0);
		}
	}
	
	if(memo[0][N]) cout<<"A"<<endl;
	else cout<<"B"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0