Description
Input
Output
Sample Input1:
3 7 1 1 3 1
3 3 2
Sample Input2:
3 7 1 1 3 2
3 3 2
Sample Input3:
3 7 1 1 3 9
3 3 2
————————————————————————————————————————————
Sample Output1:
3 4 4 4 5 5 6
6 6 6 5 5 4 4 3 2 2
Sample Output2:
4 4 5
6 5 4 3 2
Sample Output3
2
Data Constraint
建立三条队列:
1、最开始的数
2、是由某一轮的最大值x得到的⌊x*p⌋
3、是由某一轮的最大值x得到的x−⌊x*p⌋
(产生的新元素扔进队尾)
如果我们把第一条队列排序,那么第二和第三条队列也能有序,因为他们同样是与p相乘,且设经过了x天,那么第二条和第三条队列分别增长(x*q)/p和(x*q)-(x*q)/p,但已在队列中的元素增长x*q,依然保持单调递增。
对于每天增长q,在记录每个元素产生的时间t,那么第n天长度为x+(n-t)*q。
var
a,b,aa,bb,c,f,s:array[1..100000] of longint;
i,j,n,m,q,u,v,t,g:longint;
procedure kp(l,r:longint);
var
mid,k,i,j:longint;
begin
i:=l;j:=r;
mid:=s[(i+j) div 2];
repeat
while s[i]>mid do inc(i);
while s[j]<mid do dec(j);
if i<=j then
begin
k:=s[i];
s[i]:=s[j];
s[j]:=k;
inc(i);dec(j);
end;
until i>j;
if l<j then kp(l,j);
if i<r then kp(i,r);
end;
var
l,w,e,r,x,y,xx,yy:longint;
begin
readln(n,m,q,u,v,t);
for i:=1 to n do
read(s[i]);
kp(1,n);
l:=1;
x:=1;xx:=1;
y:=1;yy:=1;
for i:=1 to m do
begin
w:=-1;e:=-1;r:=-1;
if l<=n then
w:=s[l]+(i-1)*q;
if aa[x]<>0 then
e:=a[x]+(i-aa[x]-1)*q;
if bb[y]<>0 then
r:=b[y]+(i-bb[y]-1)*q;
if (w>=e)and(w>=r) then
begin
a[xx]:=trunc(w*u div v);
b[yy]:=w-a[xx];
inc(xx);inc(yy);inc(l);
c[i]:=w;
end
else
if (e>=w)and(e>=r) then
begin
a[xx]:=trunc(e*u div v);
b[yy]:=e-a[xx];
inc(xx);inc(yy);inc(x);
c[i]:=e;
end
else
begin
a[xx]:=trunc(r*u div v);
b[yy]:=r-a[xx];
inc(xx);inc(yy);inc(y);
c[i]:=r;
end;
aa[xx-1]:=i;bb[yy-1]:=i;
end;
for i:=1 to n+m do
begin
w:=-1;e:=-1;r:=-1;
if l<=n then
w:=s[l]+m*q;
if aa[x]<>0 then
e:=a[x]+(m-aa[x])*q;
if bb[y]<>0 then
r:=b[y]+(m-bb[y])*q;
if (w>=e)and(w>=r) then
begin
inc(l);inc(g);
f[g]:=w;
end
else
if (e>=w)and(e>=r) then
begin
inc(x);inc(g);
f[g]:=e;
end
else
begin
inc(y);inc(g);
f[g]:=r;
end;
end;
for i:=1 to m div t do
write(c[trunc(t*i)],' ');
writeln;
for i:=1 to (n+m) div t do
write(f[trunc(t*i)],' ');
end.