比赛 |
2017noip |
评测结果 |
C |
题目名称 |
蚯蚓 |
最终得分 |
0 |
用户昵称 |
Shadow |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2017-09-21 09:35:42 |
显示代码纯文本
#include<iostream>
#include<algorithm>
#define qaq read()
#define MXAA 7e6+100
using namespace std;
int a[1000000];
int num[150000];
int ans[7000010];
int max1,max2,max3,maxx;
double p;
int heada=1,taila=0,headb=1,headc=1,tailb=0,tailc=0;
int read()
{
int x=0,f=1,ch;
ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
return x*f;
}
int b[7000010],c[7000010];
int now=0;
int n,m,q,u,v,t;
int work()
{
int s=0;
max1=a[heada]+(now-1)*q;
max2=b[headb]+(now-headb-1)*q;
max3=c[headc]+(now-headc-1)*q;
if(headb>tailb)max2=-1;
if(heada>taila)max1=-1;
if(headc>tailc)max3=-1;
maxx=max(max(max1,max2),max3);
if(maxx==max1)heada++;
else if(maxx==max2)headb++;
else if(maxx==max3)headc++;
return maxx;
}
int top=0;
void work2()
{
while(heada<=taila||headb<=tailb||headc<=tailc)
{
max1=a[heada]+(now-1)*q;
max2=b[headb]+(now-headb-1)*q;
max3=c[headc]+(now-headc-1)*q;
if(heada>taila)max1=-1;
if(headb>tailb)max2=-1;
if(headc>tailc)max3=-1;
if(max1>=max2&&max1>=max3)ans[++top]=max1,heada++;
else if(max2>=max1&&max2>=max3)ans[++top]=max2,headb++;
else if(max3>=max1&&max3>=max2)ans[++top]=max3,headc++;
}
}
int main()
{
freopen("earthworm.in","r",stdin);
freopen("earthworm.out","w",stdout);
n=qaq;
m=qaq;
q=qaq;
u=qaq;
v=qaq;
t=qaq;
p=1.0*u/v;
for(int i=1;i<=n;i++)
num[i]=qaq;
sort(num+1,num+n+1);
for(int i=n;i>0;i--)
{ a[++taila]=num[i];}
for(int i=1;i<=m;i++)
{
now++;
int k=work();
if(i%t==0)
{
cout<<k<<' ';
}
double x=k*p;
int xx=int (x);
int y=k-xx;
b[++tailb]=max(xx,y);
c[++tailc]=min(xx,y);
}
cout<<endl;
work2();
for(int i=t;i<=m+n;i+=t)
cout<<ans[i]+q<<' ';
return 0;
}