去年在考场上,写了一个45分的堆
为什么45?因为我只开了一个2*10^5的数组。。。
好啦说说这道题
很容易发现,在砍蚯蚓的过程中,砍后分成两部分后分别具有单调性
那还用什么堆?!!3条队列就搞定了
每次比较三个队列队首元素取出最大值
还有就是要注意精度问题
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int N=8000000;
int d1[N],d2[N],d3[N];
int ans[N];
const double eps=10e-6;
int compare(const int w1,const int w2){return w1>w2;}
const int inf=0x3f3f3f3f;
int n,m,q1,t,temp;
double u,v;
int s1,s2,s3;
int t1,t2,t3;
vector<int >q;
int main()
{
freopen("earthworm.in","r",stdin);
freopen("earthworm.out","w",stdout);
cin>>n>>m>>q1>>u>>v>>t;
double x=(long long)1*u/v;
for(int i=1;i<=n;i++)
scanf("%d",&d1[i]);
t1=n;s1=s2=s3=1;
sort(d1+1,d1+n+1,compare);
for(int i=1;i<=m;i++){
int maxx=-inf;
int temp2;
if(maxx<=d1[s1]&&s1<=t1){maxx=d1[s1];temp2=1;}
if(maxx<=d2[s2]&&s2<=t2){maxx=d2[s2];temp2=2;}
if(maxx<=d3[s3]&&s3<=t3){maxx=d3[s3];temp2=3;}
if(temp2==1)s1++;
if(temp2==2)s2++;
if(temp2==3)s3++;
maxx+=temp;
ans[++ans[0]]=maxx;
int x1=(long long)1*x*maxx;
int x2=maxx-x1;
temp+=q1;
x1-=temp;x2-=temp;
d2[++t2]=x1;
d3[++t3]=x2;
}
for(int i=1;i<=m;i++)
if(i%t==0)cout<<ans[i]<<" ";
cout<<endl;
int timee=0;
while(1){
timee++;
int maxx=-inf;int d;
if(maxx<d1[s1]&&s1<=t1){d=1;maxx=d1[s1];}
if(maxx<d2[s2]&&s2<=t2){d=2;maxx=d2[s2];}
if(maxx<d3[s3]&&s3<=t3){d=3;maxx=d3[s3];}
if(d==1)s1++;
if(d==2)s2++;
if(d==3)s3++;
if(timee%t==0)cout<<maxx+temp<<" ";
if(timee==n+m)break;
}
return 0;
}