P2827 蚯蚓

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

inline int read()
{
    char c=getchar();int num=0;
    for(;!isdigit(c);c=getchar());
    for(;isdigit(c);c=getchar())
        num=num*10+c-'0';
    return num;
}

const int N=8e6+5;

int n,m,q,u,v,t,lim;
int que[4][N],head[4],tail[4];
int len,pos,maxn;

int main()
{
//    freopen("testdata.in","r",stdin);
//    freopen("233.out","w",stdout);
    n=read(),m=read(),q=read(),u=read(),v=read(),t=read();
    for(int i=1;i<=n;++i)
        que[0][i]=read();
    sort(que[0]+1,que[0]+n+1,greater<int>() );
    head[0]=1,tail[0]=n;
    head[1]=head[2]=1;
    for(int i=1;i<=m;++i)
    {
        maxn=-(1ll<<31)+1,pos=-1;
        for(int j=0;j<3;++j)
        {
            if(head[j]<=tail[j]&&maxn<que[j][head[j]])
            {
                maxn=que[j][head[j]];
                pos=j;
            }
        }
        maxn+=len;
        que[3][++tail[3]]=maxn;
        que[1][++tail[1]]=1ll*maxn*u/v;
        que[2][++tail[2]]=maxn-que[1][tail[1]];
        len+=q;
        que[1][tail[1]]-=len;
        que[2][tail[2]]-=len;
        ++head[pos];
    }
    tail[3]=0;
    for(int i=t;i<=m;i+=t)
        cout<<que[3][i]<<' ';
    puts("");
    for(int i=1;i<=n+m;++i)
    {
        maxn=-(1ll<<31)+1,pos=-1;
        for(int j=0;j<3;++j)
        {
            if(head[j]<=tail[j]&&maxn<que[j][head[j]])
            {
                maxn=que[j][head[j]];
                pos=j;
            }
        }
        que[3][++tail[3]]=maxn;
        ++head[pos];
    }
    for(int i=t;i<=n+m;i+=t)
        cout<<que[3][i]+len<<' ';
    return 0;
}

 

posted @ 2018-09-12 11:26  whymhe  阅读(144)  评论(0编辑  收藏  举报