链接:Miku
---------------------------------
本题的关键就在于隐藏的单调性
开三个队列,分别放没切的,切出来的大的,切出来的小的。
-----------------------------------
#include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cmath> const int maxn =7000005; using namespace std; bool cmp(int a,int b){ return a>b; } priority_queue <int> ans; int c1[maxn],wh[maxn],c2[maxn]; int n,m,q,u,v,t; int s; double p; int h,h1,h2; int t0,t1,t2; int tmp,top; int p1,p2; int main(){ scanf("%d%d%d%d%d%d",&n,&m,&q,&u,&v,&t); p=(double)u/v; for(int i=1;i<=n;++i) scanf("%d",&wh[i]); t0=n;//只有whole没切过是满的 t1=t2=0;h=h1=h2=1; sort(wh+1,wh+n+1,cmp); for(int i=1;i<=m;++i){//深入理解?? if(h>t0){//取出最大 if(c1[h1]>c2[h2]) { top=c1[h1]; h1++; }else{ top=c2[h2]; h2++; } }else{ if(wh[h]>=c1[h1]&&wh[h]>=c2[h2]){ top=wh[h]; h++; }else if(c1[h1]>=wh[h]&&c1[h1]>=c2[h2]){ top=c1[h1]; h1++; }else{ top=c2[h2]; ++h2; } } top+=s;//根据相对性解决 //相对变绝对 p1=floor((double)top*p);//切 p2=top-p1; s+=q;// p1-=s;//他们享受不到本次增加,别人都加了相对就是他们减了 p2-=s;//事实上就-了个q t1++; t2++; c1[t1]=p1;//入队 c2[t2]=p2; if(i%t==0) cout<<top<<" "; } cout<<endl; for(int i=h;i<=t0;++i)//扔到一块并输出 ans.push(wh[i]); for(int i=h1;i<=t1;++i) ans.push(c1[i]); for(int i=h2;i<=t2;++i) ans.push(c2[i]); for(int i=1;!ans.empty();++i){ if(i%t==0) cout<<ans.top()+s<<" "; ans.pop(); } return 0; }