|  | 
|  | 
| back to board | To Admins, why crash 1? I don't understand, why crash(access violation) in test1 ??!!
 uses math;
 var
 n,k,l,m,d,a,i,j:longint;
 p:array[0..66000] of longint;
 
 begin
 assign(input,'input.txt'); reset(input);
 assign(output,'output.txt'); rewrite(output);
 readln(m);
 n:=0;
 repeat
 inc(n);
 read(p[n]);
 until p[n]=-1;
 dec(n);
 
 k:=1; d:=n;
 
 while 1 shl k<n do inc(k);
 
 n:=1 shl k;
 
 for l:=d+1 to n do
 p[l]:=-1;
 
 
 for k:=n downto 1 do
 begin
 p[k+n-1]:=p[k];
 end;
 
 for k:=n-1 downto 1 do
 begin
 p[k]:=max(p[k*2],p[k*2+1]);
 end;
 
 for k:=0 to d-m do
 begin
 i:=k+n; j:=k+m-1+n;
 a:=-1;
 
 while i<j do
 begin
 if odd(i) then begin a:=max(a,p[i]); inc(i); end;
 if not odd(j) then begin a:=max(a,p[j]); dec(j); end;
 i:=i div 2; j:=j div 2;
 end;
 a:=max(a,p[i]);
 
 writeln(a);
 end;
 
 end.
 
 
 
 I use {$R+} on Delphi, FP, TP - nothing Crash.
 
 Edited by author 08.10.2009 11:30
Because of input.txt/output.txt ? (-)Re: Because of input.txt/output.txt ? (-) Thank you. Now wa2... | 
 | 
|