Solution earthworm
Subject to the effect: In the beginning there \ (n \) only earthworms, you operate \ (m \) times. Every time grasping the longest one, note length \ (the X-\) , cut into \ (\ lfloor PX \ rfloor \) , \ (X-\ lfloor PX \ rfloor \) two back, while in addition to these two All worms only increase the length of the outer \ (Q \) , each Q earthworms cut length, \ (m \) length after the operations of all the earthworms
queue
First we solve collective increase in addition to the new \ (q \) of the problem, we can maintain a delta \ (Delta \) , indicates the length of all the earthworms have increased \ (Delta \) , two new earthworms without \ (Q \) , which we will length minus \ (Q \) then can be treated, so there may be negative in the process
It is not difficult to think of a simple analog rough idea, with a large root heap, while maintaining throw back after each increment to take the biggest cut \ (Delta \) . But this will take a \ (log \) , can not afford
The key is added after two earthworms than the original cut short , so every time we get out of the earthworm is decreasing length (without considering the incremental \ (Delta \) ), with the sequences into this topic and ideas, with a queue \ (Q_1 \) stores the original \ (n-\) earthworms (like row a sequence), \ (Q_2 \) storing cut \ (\ lfloor px \ rfloor \ ) earthworms, \ (Q_3 \) storing cut to \ (x- \ lfloor px \ rfloor \) earthworms, each taking from three queue maximum queue head, cut worms were thrown \ (Q_2 \) , \ (Q_3 \) maintenance \ (Delta \ ) to
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 100;
inline int read(){
int x = 0;char c = getchar();
while(!isdigit(c))c = getchar();
while(isdigit(c))x = x * 10 + c - '0',c = getchar();
return x;
}
queue<ll> Q[4];
int val[maxn],n,m,q,u,v,t;
ll delta;
inline int findmax(){
int res = 0;
for(int i = 1;i <= 3;i++)
if(!Q[i].empty() && (!res || Q[i].front() > Q[res].front()))res = i;
return res;
}
inline ll cut(ll x){return 1ll * u * x / v;}
inline void solve(int tim){
ll x = Q[findmax()].front();Q[findmax()].pop();
if(tim % t == 0)printf("%lld ",x + delta);
Q[2].push(cut(x + delta) - delta - q);Q[3].push(x - cut(x + delta) - q);
delta += q;
}
int main(){
n = read(),m = read(),q = read(),u = read(),v = read(),t = read();
for(int i = 1;i <= n;i++)val[i] = read();
sort(val + 1,val + 1 + n);
for(int i = n;i >= 1;i--)Q[1].push(val[i]);
for(int i = 1;i <= m;i++)solve(i);
putchar('\n');
for(int i = 1;i * t <= n + m;i++){
for(int j = 1;j <= t - 1;j++)
Q[findmax()].pop();
printf("%lld ",Q[findmax()].front() + delta);
Q[findmax()].pop();
}
putchar('\n');
return 0;
}