|
var
a:array[0..30000] of longint;
left,right,num:array[1..100000] of longint;
n,m,i,j,k,x,y,s:longint;
flag:boolean;
procedure create(now,l,r:longint);
var
mid:longint;
begin
left[now]:=l;
right[now]:=r;
if l=r then num[now]:=0
else begin
mid:=(l+r) div 2;
create(now*2,l,mid);
create(now*2+1,mid+1,r);
num[now]:=num[now*2]+num[now*2+1];
end;
end;
procedure tongji(now,x:longint);
var
mid:longint;
begin
if flag=true then exit;
mid:=(left[now]+right[now]) div 2;
if x<mid then
tongji(now*2,x);
if flag=true then exit;
if x=mid then begin s:=s+num[now*2]; flag:=true; if flag=true then exit; end;
if flag=true then exit;
if x>mid then begin s:=s+num[now*2];
tongji(now*2+1,x); end;
if flag=true then exit;
end;
procedure insert(now,x:longint);
var
mid:longint;
begin
if left[now]=right[now] then
inc(num[now])
else begin
mid:=(left[now]+right[now]) div 2;
if x<=mid then insert(now*2,x)
else insert(now*2+1,x);
num[now]:=num[now*2]+num[now*2+1];
end;
end;
begin
fillchar(left,sizeof(left),0);
fillchar(right,sizeof(right),0);
fillchar(num,sizeof(num),0);
fillchar(a,sizeof(a),0);
create(1,0,32300);
readln(n);
for i:=1 to n do
begin
readln(x,y);
flag:=false;
s:=0;
tongji(1,x);
inc(a[s]);
insert(1,x);
end;
for i:=0 to n-1 do
writeln(a[i]);
end.
权当练手= = |
|