結果

問題 No.973 余興
ユーザー kotatsugamekotatsugame
提出日時 2020-01-17 23:34:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 73,304 KB
実行使用メモリ 199,220 KB
最終ジャッジ日時 2023-09-08 08:04:30
合計ジャッジ時間 43,659 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,157 ms
198,948 KB
testcase_01 AC 1,156 ms
198,944 KB
testcase_02 AC 1,144 ms
199,008 KB
testcase_03 AC 1,197 ms
198,952 KB
testcase_04 AC 1,150 ms
198,884 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,069 ms
191,340 KB
testcase_11 AC 370 ms
73,912 KB
testcase_12 AC 367 ms
73,996 KB
testcase_13 WA -
testcase_14 AC 362 ms
73,220 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 16 ms
8,264 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 27 ms
11,368 KB
testcase_23 AC 21 ms
9,760 KB
testcase_24 AC 21 ms
9,696 KB
testcase_25 AC 10 ms
6,188 KB
testcase_26 AC 17 ms
8,264 KB
testcase_27 AC 33 ms
12,180 KB
testcase_28 WA -
testcase_29 AC 21 ms
9,580 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,282 ms
198,520 KB
testcase_35 AC 1,300 ms
198,824 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,266 ms
198,416 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 1,224 ms
198,896 KB
testcase_47 WA -
testcase_48 AC 1,233 ms
198,948 KB
testcase_49 WA -
testcase_50 AC 1,275 ms
197,656 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,239 ms
195,392 KB
testcase_54 AC 1,304 ms
198,948 KB
testcase_55 AC 1,329 ms
198,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:34:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   34 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
int N;
long A[5050],X,S[5050];
int getL[5050],getR[5050];
main()
{
	cin>>N>>X;
	for(int i=1;i<=N;i++)
	{
		cin>>A[i];
		S[i+1]=S[i]+A[i];
	}
	for(int i=1;i<=N;i++)
	{
		int L=i+1,R=N+2;
		while(R-L>1)
		{
			int M=(L+R)/2;
			if(S[M]-S[i]<=X)L=M;
			else R=M;
		}
		getL[i]=L;
	}
	for(int i=2;i<=N+1;i++)
	{
		int L=0,R=i-1;
		while(R-L>1)
		{
			int M=(L+R)/2;
			if(S[i]-S[M]<=X)R=M;
			else L=M;
		}
		getR[i]=R;
	}
	vector<BIT<int> >dpL(N+2,BIT<int>(N+1));
	vector<BIT<int> >dpR(N+2,BIT<int>(N+1));
	for(int i=1;i<=N;i++)
	{
		dpL[i].add(i+1,1);
		dpR[i+1].add(i,1);
	}
	for(int k=2;k<=N;k++)
	{
		for(int i=1;i+k<=N+1;i++)
		{
			int l=i,r=i+k;
			bool now=false;
			if(dpR[r].sum(min(getL[l],r))!=dpR[r].sum(l+1))now=true;
			if(dpL[l].sum(min(l,getR[r])-1)!=dpL[l].sum(r-1))now=true;
			if(!now)
			{
				dpL[l].add(r,1);
				dpR[r].add(l,1);
			}
		}
	}
	cout<<(dpL[1].sum(N+1)==dpL[1].sum(N)?"A":"B")<<endl;
}
0