- 不差钱
- 2009-09-17 23:59:25 @
const maxn=1 shl 20;
var i,j,n,m,k,price,pp:longint;
t,c,a:array[-1000..10000000] of longint;
function lowbit(x:longint):longint;
begin
lowbit:=((x-1) xor x) and x;
end;
procedure add(x,d:longint);
begin
while x=maxn)or(cnt+c[ans]>=k) then ans:=ans-(1shl j)
else cnt:=cnt+c[ans];
end;
exit(ans+1);
end;
begin
fillchar(a,sizeof(a),true);
readln(price);
i:=0;
repeat
read(pp);
if pp=0 then exit;
readln(n);
case pp of
1:begin inc(i);
t[i]:=n;
add(i,n);
inc(a[n]);end;
2:dec(a[t[n]]);
3:begin
k:=find(n);
if k>price then writeln('Dui bu qi,Mei you.')
else begin
if a[k]
0 条评论
目前还没有评论...