https://www.luogu.org/problem/show?pid=2827
就是贪心 从a[1],a[2],a[3]中取出最大的一个,切掉,切下来的放到a[1],a[2]中
因为被切的虫子在这一秒不增长 所以可以将其减去q 来保证虫子们的数量关系的正确性
最后归并三个数组得到答案数组
注意:要取模卡常
上代码
var a:array[1..3,1..7100000] of longint;
d:array[1..10000000] of longint;
b,c,h:array[1..3] of longint;
i,j,k,l,m,n,q,w,t,v,u,ct,cut,h1,h2,h3,tot,hj:longint;
p:double;
procedure sort(l,r: longint);
var i,j,x,y: longint;
begin
i:=l; j:=r; x:=a[3,(l+r) div 2];
repeat
while a[3,i]>x do inc(i);
while x>a[3,j] do dec(j);
if not(i>j) then
begin
y:=a[3,i]; a[3,i]:=a[3,j]; a[3,j]:=y;
inc(i); j:=j-1;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
for i:=1 to 3 do begin b[i]:=1;c[i]:=1; end;
fillchar(a,sizeof(a),128);
readln(n,m,q,u,v,t);
p:=u/v;
for i:=1 to n do read(a[3,i]); readln;
sort(1,n);
for i:=1 to m do begin
if(a[1,b[1]]>=a[2,b[2]])and((a[1,b[1]])>=a[3,b[3]]) then
begin ct:=1; cut:=a[1,b[1]]; end else
if(a[2,b[2]]>=a[1,b[1]])and((a[2,b[2]])>=a[3,b[3]]) then
begin ct:=2; cut:=a[2,b[2]]; end else
if(a[3,b[3]]>=(a[2,b[2]]+k))and((a[1,b[1]])<=a[3,b[3]]) then
begin ct:=3; cut:=a[3,b[3]];end;
inc(b[ct]);
cut:=cut+(i-1)*q;
a[1,c[1]]:=trunc(cut*u/v)-q*i;
a[2,c[2]]:=cut-trunc(cut*u/v)-i*q;
inc(c[1]);inc(c[2]);
inc(hj);
if hj=t then begin write(cut,' '); hj:=0; end;
end;
writeln;
h[1]:=b[1];h[2]:=b[2];h[3]:=b[3];
while tot < m+n do begin
inc(tot);
if(a[1,h[1]]>=a[2,h[2]])and(a[1,h[1]]>=a[3,h[3]]) then begin
ct:=1; d[tot]:=a[1,h[1]] end;
if(a[2,h[2]]>=a[1,h[1]])and(a[2,h[2]]>=a[3,h[3]]) then begin
ct:=2; d[tot]:=a[2,h[2]] end;
if(a[3,h[3]]>=a[2,h[2]])and(a[3,h[3]]>=a[1,h[1]]) then begin
ct:=3; d[tot]:=a[3,h[3]] end;
inc(h[ct]);
end; k:=m*q; i:=t;
while i<=(m+n) do begin write(d[i]+k,' '); i:=i+t; end;
end.
END.