結果

問題 No.973 余興
ユーザー kotatsugamekotatsugame
提出日時 2020-01-17 23:25:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,412 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 73,176 KB
実行使用メモリ 199,204 KB
最終ジャッジ日時 2023-09-08 07:45:01
合計ジャッジ時間 54,886 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,137 ms
198,884 KB
testcase_01 AC 1,096 ms
199,200 KB
testcase_02 AC 1,077 ms
198,920 KB
testcase_03 AC 1,068 ms
198,880 KB
testcase_04 AC 1,049 ms
199,020 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,033 ms
191,364 KB
testcase_11 AC 614 ms
74,040 KB
testcase_12 AC 595 ms
73,792 KB
testcase_13 WA -
testcase_14 AC 602 ms
73,328 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 18 ms
8,328 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 29 ms
11,356 KB
testcase_23 AC 23 ms
9,836 KB
testcase_24 AC 22 ms
9,904 KB
testcase_25 AC 10 ms
6,268 KB
testcase_26 AC 17 ms
8,368 KB
testcase_27 AC 33 ms
12,276 KB
testcase_28 WA -
testcase_29 AC 22 ms
9,644 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,892 ms
198,392 KB
testcase_35 AC 2,071 ms
198,992 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,856 ms
198,396 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 1,656 ms
198,984 KB
testcase_47 WA -
testcase_48 AC 1,668 ms
198,924 KB
testcase_49 WA -
testcase_50 AC 1,657 ms
197,600 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,988 ms
195,500 KB
testcase_54 AC 1,821 ms
199,024 KB
testcase_55 AC 1,848 ms
198,928 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[5000],X,S[5001];
int getL[5001],getR[5001];
main()
{
	cin>>N>>X;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		S[i+1]=S[i]+A[i];
	}
	for(int i=0;i<N;i++)
	{
		int L=i+1,R=N+1;
		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=1;i<=N;i++)
	{
		int L=-1,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=0;i+k<=N;i++)
		{
			int l=i,r=i+k;
			bool now=false;
			if(dpR[r+1].sum(getL[l]+2)==dpR[r+1].sum(l+2))now=true;
			if(dpL[l+1].sum(getR[r]+1)==dpL[l+1].sum(r+1))now=true;
			if(!now)
			{
				dpL[l+1].add(r+1,1);
				dpR[r+1].add(l+1,1);
			}
		}
	}
	cout<<(dpL[1].sum(N+1)==dpL[1].sum(N)?"A":"B")<<endl;
}
0