Pagini recente » Cod sursa (job #2760399) | Cod sursa (job #2373497) | Cod sursa (job #1101178) | Cod sursa (job #1889518) | Cod sursa (job #142136)
Cod sursa(job #142136)
var v,c,cl:array[1..200000]of longint;
n,i,j,k,u,l:longint;
f:text;
procedure arb(o,t,a,b:longint);
begin
v[o]:=v[o]-1;
if a<b then begin if v[o*2]>=t then arb(o*2,t,a,(b+a) div 2)
else arb(o*2+1,t-v[o*2],(b+a)div 2+1,b);
end
else l:=a;
end;
begin
assign(f,'schi.in');
reset(f);
read(f,n);
for i:=1 to n do
read(f,c[i]);
close(f);
while 1 shl u<n do
u:=u+1;
for i:=1 shl(u) to 1 shl (u)+n-1 do
v[i]:=1;
for j:=u-1 downto 0 do
for i:=(1 shl j) to 1 shl (j+1)-1 do
v[i]:=v[i*2]+v[i*2+1];
for i:=n downto 1 do
begin
arb(1,c[i],1,1 shl u);
cl[l]:=i;
end;
assign(f,'schi.out');
rewrite(f);
for i:=1 to n do
writeln(f,cl[i]);
close(f);
end.