社区讨论

答案都比标准答案多一部分 求助各位大佬

P2827[NOIP 2016 提高组] 蚯蚓参与者 9已保存回复 9

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
9 条
当前快照
1 份
快照标识符
@mi6yz2co
此快照首次捕获于
2025/11/20 13:07
4 个月前
此快照最后确认于
2025/11/20 13:07
4 个月前
查看原帖
样例一,二 的答案都比标准答案要长 长的部分是7,剩下的为正确答案
关于中间操作用的是年鉴的思想,不知道为什么错了......
CPP
#include<cstdio>
#include<iostream>
#include<queue> 
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
priority_queue<LL,vector<LL>,less<LL> >q;							//大根堆 
int n,m,qq,u,v,t;
LL a[110000],b[110000],c[110000];
LL guo,ans[7110000],ans2[110000],we[110000],tot,tot2;
int cmp(const int &x,const int &y)
{
	return x>y;
}
LL sum,y,num,jishu;
queue<LL> aa,q1,q2;
int main()
{
	scanf("%d%d%d%d%d%d",&n,&m,&qq,&u,&v,&t);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		aa.push(a[i]);
	for(int i=1;i<=m;i++)
	{
		++jishu;
		LL maxx=0,flag=0;
		if(!aa.empty()&&maxx<aa.front())
		{
			flag=1;
			maxx=aa.front();
		}
			
		if(!q1.empty()&&maxx<q1.front())
		{
			flag=2;
			maxx=q1.front();
		}
			
		if(!q2.empty()&&maxx<q2.front())
		{
			flag=3;
			maxx=q2.front();
		}
		if(flag==1)
			aa.pop();
		else if(flag==2)
			q1.pop();
		else if(flag==3)
			q2.pop();
		//maxx=max(aa.front(),max(q1.front(),q2.front()));
		cout<<maxx<<endl;
		
		num=maxx+sum;	cout<<sum<<" "<<num<<endl;
		ans[++tot]=num;
		
		LL part1=(int)u*num/v;
		
		LL part2=num-part1;
		if(part1<part2)
			swap(part1,part2);
		cout<<part1<<" "<<part2<<endl;
		q1.push(part1-sum);
		q2.push(part2-sum);
		sum+=qq;
	}
	while(!aa.empty())
	{
		ans2[++tot2]=aa.front()+jishu*qq;
		aa.pop();
	}
	while(!q1.empty())
	{
		ans2[++tot2]=q1.front()+jishu*qq;
		q1.pop();
	}
	while(!q2.empty())
	{
		ans2[++tot2]=q2.front()+jishu*qq;
		q2.pop();
	}
	sort(ans2+1,ans2+tot2+1,cmp);
	for(int i=1;i*t<=tot;i++)
		printf("%d ",ans[i*t]);
	printf("\n");
	for(int i=1;i*t<=tot2;i++)
		printf("%d ",ans2[i*t]);
	printf("\n");
	return 0;
}
/*
3 4 4 4 5 5 6
6 6 6 5 5 4 4 3 2 2
*/

回复

9 条回复,欢迎继续交流。

正在加载回复...