QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559331#6355. 5Jessica2333WA 3ms13816kbC++141.6kb2024-09-11 21:24:472024-09-11 21:24:47

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 21:24:47]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:13816kb
  • [2024-09-11 21:24:47]
  • 提交

answer

#include<iostream>
#include<vector>
using namespace std;
int N,S,A[200008],buc[200008],W[508],V[508];
struct NODE{
	int l,r;
};
vector<NODE> f[400008];
int O;
void add_(int p,int l,int r)
{
	if(f[p].empty()) f[p].push_back({l,r});
	else
	{
		vector<NODE> vec;
		for(auto v:f[p]) vec.push_back(v);
		f[p].clear();
		bool flag=1;
		for(auto v:vec)
		{
			if(v.r<l-1) f[p].push_back(v);
			else if(l<=v.l&&v.r<=r) continue;
			else if(v.l>r+1) f[p].push_back({l,r}),f[p].push_back(v),flag=0;
			else l=min(l,v.l),r=max(r,v.r);
		}
		if(flag) f[p].push_back({l,r});
	}
}
signed main()
{
	freopen("data.in","r",stdin);
	cin>>N>>S;O=N;
	for(int i=1;i<=N;i++) cin>>A[i],buc[A[i]]++;
	int N2=0;
	for(int i=0;i<=S;i++)
	{
//		if(N==36000&&buc[A[i]]) cout<<A[i]<<" "<<buc[A[i]]<<" ";
		for(int j=0;buc[i];j++) V[++N2]=i*min(1<<j,buc[i]),W[N2]=min(1<<j,buc[i]),buc[i]-=W[N2];
	}
	f[O].push_back({0,0});
	for(int i=1;i<=N2;i++)
	{
		if(V[i]>0)
		{
			for(int j=S+O-1;j>=0;j--)
			{
				if(j+V[i]-W[i]>=S+O) continue;
//				if(f[j].size()>30)
//				{
//					cout<<"orz\n";
//					return 0;
//				}
				for(auto v:f[j])
				{
					add_(j+V[i]-W[i],v.l+W[i],v.r+W[i]);
				}
			}
		}
		else
		{
			for(int j=0;j<S+O;j++)
			{
				if(j+V[i]-W[i]<0) continue;
//				if(f[j].size()>30)
//				{
//					cout<<"orz\n";
//					return 0;
//				}
				for(auto v:f[j])
				{
					add_(j+V[i]-W[i],v.l+W[i],v.r+W[i]);
				}
			}
		}
	}
	long long ans=0;
	for(int i=0;i<S+O;i++) for(auto v:f[i]) ans+=v.r-v.l+1;
	cout<<ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 13816kb

input:

7 9
0 0 0 1 1 2 5

output:

0

result:

wrong answer 1st numbers differ - expected: '42', found: '0'