Jzoj4907 蚯蚓

题意:noip2016d2t2

配对堆好题,直接上pbds

#pragma GCC opitmize("O3")
#pragma G++ opitmize("O3")
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<ext\pb_ds\priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
__gnu_pbds::priority_queue <int,less<int>,pairing_heap_tag> q;
inline int r(){
	char c = getchar(); int x = 0;
	for(;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+c-48;
	return x;
}
int main(){
	freopen("earthworm.in","r",stdin);
	freopen("earthworm.out","w",stdout);
	int n=r(),m=r(),Q=r(),u=r(),v=r(),t=r(),sq=0;
	for(int x,i=n;i;--i) q.push(r());
	for(int x,y,z=t,i=m;i;--i){
		x=q.top(); q.pop();
		if(--z==0) printf("%d ",x+sq),z=t;
		q.push((y=(x+sq)*u/v)-sq-Q);
		q.push(x-y-Q);
		sq+=Q;
	}
	puts("");
	for(int z=t,i=m+n,x;i;--i){
		if(--z==0) printf("%d ",q.top()+sq),z=t;
		q.pop();
	}
}

posted @ 2017-11-14 21:32  扩展的灰(Extended_Ash)  阅读(140)  评论(0编辑  收藏  举报