結果

問題 No.973 余興
ユーザー kotatsugamekotatsugame
提出日時 2020-01-17 23:34:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 74,544 KB
実行使用メモリ 199,152 KB
最終ジャッジ日時 2023-09-08 08:05:57
合計ジャッジ時間 57,523 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,687 ms
198,932 KB
testcase_01 WA -
testcase_02 AC 1,738 ms
198,880 KB
testcase_03 AC 1,648 ms
198,888 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,695 ms
198,924 KB
testcase_07 WA -
testcase_08 AC 1,649 ms
198,476 KB
testcase_09 AC 1,657 ms
199,012 KB
testcase_10 AC 1,573 ms
191,264 KB
testcase_11 WA -
testcase_12 AC 468 ms
73,740 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 35 ms
11,448 KB
testcase_16 AC 36 ms
11,448 KB
testcase_17 AC 21 ms
8,564 KB
testcase_18 AC 26 ms
9,824 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 35 ms
11,348 KB
testcase_22 AC 34 ms
11,420 KB
testcase_23 AC 25 ms
9,748 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 44 ms
12,300 KB
testcase_28 AC 28 ms
9,824 KB
testcase_29 WA -
testcase_30 AC 1,657 ms
198,832 KB
testcase_31 AC 1,631 ms
198,832 KB
testcase_32 AC 1,675 ms
199,028 KB
testcase_33 AC 1,646 ms
198,880 KB
testcase_34 AC 1,600 ms
198,444 KB
testcase_35 WA -
testcase_36 AC 1,596 ms
193,860 KB
testcase_37 AC 1,582 ms
193,876 KB
testcase_38 AC 1,619 ms
198,404 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 1,654 ms
198,888 KB
testcase_49 AC 1,434 ms
183,648 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,538 ms
195,436 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(max(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