|
|
вернуться в форумHelp me . I don't know why I got Wrong Anser Послано XueMao 27 июн 2003 21:04 Program Memory_Management; Type Lion=Record Num,Time:word; End; Var i,j,k,k1,m,n,r,t,Pos:longint; c:char; Ld,Rd,Left,Right:array[0..30001] of Word; Action:array[0..80001] of Lion; Time:array[0..30001] of Word; Procedure MakeTree(x,Min:word); Var k:Word; Begin if x=Min then begin Left[x]:=0; Right[x]:=0; Ld[x]:=0; Rd[x]:=0; exit; end; k:=(x-Min) shr 1 +Min; Left[x]:=k; MakeTree(k,Min); Ld[x]:=Ld[k]+Rd[k]+1; if x-1>k then begin Right[x]:=x-1; MakeTree(x-1,k+1); Rd[x]:=Ld[x-1]+Rd[x-1]+1; end else begin Right[x]:=0; Rd[x]:=0; end; End; Procedure Add(x:Word); Begin inc(t); Action[t].Num:=x; Action[t].Time:=k+600; Time[x]:=k+600; writeln(x); end; Procedure Find_Del(x:Word); Begin if (Ld[x]=0)and(Rd[x]=0) then Add(x) else if Ld[x]>0 then begin Find_Del(Left[x]); dec(Ld[x]); end else begin Find_Del(Right[x]); dec(Rd[x]); end End; Procedure Find_Inc(x:longint); Begin if x=Pos then exit; if Left[x]>=Pos then begin Find_Inc(Left[x]); inc(Ld[x]); end else begin Find_Inc(Right[x]); inc(Rd[x]); end; End; Begin Fillchar(Time,sizeof(Time),0); MakeTree(30001,1); r:=1; t:=0; while not(eof) do begin read(k); repeat read(c); until c<>' '; while (r<=t)and(Action[r].time<=k) do begin if Action[r].time=time[Action[r].Num] then begin Pos:=Action[r].Num; Find_Inc(30001); Time[Action[r].Num]:=0; end; inc(r); end; if c='.' then begin read(k1); if k<Time[k1] then begin writeln('+'); inc(t); Action[t].Num:=k1; Action[t].time:=k+600; Time[k1]:=k+600; end else writeln('-'); end else Find_Del(30001); readln; end; End. Re: Help me . I don't know why I got Wrong Anser Послано XueMao 4 июл 2003 18:01 Sorry ! How careless I am ! I got ac now |
|
|