蛐蛐国最近蚯蚓成灾了!

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define INF 0x3f3f3f
#define N 7000007
using namespace std;
inline int read() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
    return x * f;
}
int n,m,q,u,v,t,ofst;   //offsetÆ«ÒÆÁ¿ 
int h=1,h1=1,h2=1,t1,t2;    //t1£¬t2²ÅÊÇÊý×é´óС£¬h1£¬h2ÊÇ¿ÉÓÃ×î´óÖµ 
int s[N],c1[N],c2[N];   //Ô­Êý×飬cut1£¬cut2
priority_queue<int> pq;
bool cmp(int a,int b) {
    return a > b;
}
int main()
{
    n = read(), m = read(), q = read(), u = read() ,v = read() ,t = read();
    double p = (double)u / (double)v;
    for(int i=1;i<=n;++i)
        s[i] = read();
    sort(s+1, s+1+n, cmp);
    for(int i=1;i<=m;++i) {
        int tp,a1,a2;
        if(h > n) c1[h1]>c2[h2] ? tp=c1[h1++] : tp=c2[h2++];
        else if(s[h]>=c1[h1] && s[h]>=c2[h2]) tp = s[h++];  //
        else if(c1[h1]>=s[h] && c1[h1]>=c2[h2]) tp = c1[h1++];
        else tp = c2[h2++];
        tp += ofst; a1 = floor(p*(double)tp); a2 = tp - a1;
        ofst += q; a1 -= ofst; a2 -= ofst;
        c1[++t1] = a1, c2[++t2] = a2;
        if(i % t==0) printf("%d ",tp);
    }
    putchar('\n');
    for(int i=h;i<=n;++i) pq.push(s[i]);
    for(int i=h1;i<=t1;++i) pq.push(c1[i]);
    for(int i=h2;i<=t2;++i) pq.push(c2[i]);
    int i = 0;
    while(!pq.empty()) {
        ++i; if(i%t==0) printf("%d ",pq.top()+ofst); pq.pop();
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值