結果

問題 No.973 余興
ユーザー HIR180HIR180
提出日時 2020-01-17 21:43:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,697 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 185,816 KB
実行使用メモリ 125,168 KB
最終ジャッジ日時 2023-09-08 02:09:19
合計ジャッジ時間 29,576 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 922 ms
104,752 KB
testcase_01 AC 928 ms
104,752 KB
testcase_02 AC 907 ms
104,860 KB
testcase_03 AC 898 ms
104,648 KB
testcase_04 AC 923 ms
104,752 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 868 ms
104,232 KB
testcase_11 AC 223 ms
78,216 KB
testcase_12 AC 213 ms
78,200 KB
testcase_13 WA -
testcase_14 AC 219 ms
78,028 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 22 ms
27,720 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 33 ms
34,004 KB
testcase_23 AC 28 ms
34,028 KB
testcase_24 AC 28 ms
33,928 KB
testcase_25 AC 15 ms
23,600 KB
testcase_26 AC 21 ms
27,696 KB
testcase_27 AC 38 ms
38,064 KB
testcase_28 WA -
testcase_29 AC 28 ms
34,128 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 646 ms
104,840 KB
testcase_35 AC 635 ms
104,688 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 626 ms
104,716 KB
testcase_39 WA -
testcase_40 AC 2 ms
7,540 KB
testcase_41 AC 2 ms
7,452 KB
testcase_42 AC 2 ms
7,624 KB
testcase_43 WA -
testcase_44 AC 2 ms
7,560 KB
testcase_45 WA -
testcase_46 AC 521 ms
105,432 KB
testcase_47 WA -
testcase_48 AC 530 ms
104,660 KB
testcase_49 WA -
testcase_50 AC 535 ms
104,616 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 755 ms
104,480 KB
testcase_54 AC 783 ms
104,696 KB
testcase_55 AC 853 ms
104,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,x,a[5005];
struct BIT
{
	short bit[5005];
	void add(int i,short x)
	{
		for(int s=i;s<5005;s+=s&-s) bit[s]+=x;
	}
	short sum(int i)
	{
		short res=0;
		for(int s=i;s>0;s-=s&-s) res+=bit[s];
		return res;
	}
}bitL[5005],bitR[5005];

bool dp[5005][5005];
int goL[5005],goR[5005];
int main(){
	scanf("%d%d",&n,&x);
	repn(i,n) scanf("%d",&a[i]);
	repn(i,n){
		goL[i] = n;
		ll sum = 0;
		for(int j=i;j<=n;j++){
			sum += a[j];
			if(sum > x){
				goL[i] = j-1; break;
			}
		}
		goR[i] = 1;
		sum = 0;
		for(int j=i;j>=0;j--){
			sum += a[j];
			if(sum > x){
				goR[i] = j+1; break;
			}
		}
	}
	for(int len=1;len<=n;len++){
		for(int i=1;i+len-1<=n;i++){
			int L = i, R = i+len-1;
			int x = min(goL[L],R-1);
			if(L <= x){
				if(bitR[R].sum(x+1) > bitR[R].sum(L)){
					dp[L][R] = 1; goto nxt;
				}
			}
			x = max(goR[R],L+1);
			if(x <= R){
				if(bitL[L].sum(R-1) > bitL[R].sum(x-2)){
					dp[L][R] = 1; goto nxt;
				}
			}
			bitL[L].add(R,1);
			bitR[R].add(L,1);
			nxt:;
		}
	}
	puts(dp[1][n]?"A":"B");
}
0