记录编号 544916 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 [NOIP 2016]蚯蚓 最终得分 100
用户昵称 GravatarHale 是否通过 通过
代码语言 C++ 运行时间 1.223 s
提交时间 2019-10-23 21:03:18 内存使用 93.77 MiB
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int INF = ~0U>>1;
const int M = 7e6 + 10;
int cut1[M],now[M],cut2[M];
int n, m, q, u, v, t, add, h, h1, h2, t0, t1, t2;
double p;

inline int read() 
{
    int res = 0, flag = 1;
    char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == '-') flag = -1;
    for(; isdigit(c); c = getchar()) res = (res<<3) + (res<<1) + (c^48);
    return res * flag;
}

inline bool cmp(const int &x,const int &y)
{
    return x > y;
}

int main()
{
    freopen("earthworm.in","r",stdin);
	freopen("earthworm.out","w",stdout);
	n = read(), m = read(), q = read(), u = read(), v = read(), t = read();
    p = (double)u/v;
    for(t0 = 1; t0 <= n; t0++) now[t0] = read();
    t0--;
    t1 = t2 = 0;
    h = h1 = h2 = 1;
    sort(now+1, now+t0+1, cmp);
    int top;
    for(register int i = 1; i <= m; i++)
	{
        if(h > t0) 
		{
            if(cut1[h1] > cut2[h2]) top = cut1[h1++];
            else top = cut2[h2++];
        }
        else if(now[h]>=cut1[h1] && now[h]>=cut2[h2]) top = now[h], h++;
        else if(cut1[h1]>=cut2[h2] && now[h]<=cut1[h1]) top = cut1[h1], h1++;
        else top = cut2[h2], h2++;
        top += add;
        int e1 = floor((double)top*p), e2 = top - e1;
        add += q;
        e1 -= add, e2 -= add;
        cut1[++t1] = e1, cut2[++t2] = e2;
        if(!(i%t)) printf("%d ", top);
    }
    printf("\n");
    int i=1;
    while(h<=t0 || h1<=t1 || h2<=t2) 
	{
        int flag, Max = -INF;
        if(h <= t0 && now[h] > Max) Max = now[h], flag = 1;
        if(h1 <= t1 && cut1[h1] > Max) Max = cut1[h1], flag = 2;
        if(h2 <= t2 && cut2[h2] > Max) Max = cut2[h2], flag = 3;
        if(flag == 1) h++;
        else if(flag == 2) h1++;
        else h2++;
        if(!(i%t)) printf("%d ", Max + add);
        i++;
    }
    return 0;
}