|
|
вернуться в форумHelp me!!!! I have MLE!! Why Послано snake 24 июн 2004 22:18 {$APPTYPE CONSOLE} var m:array[0..250000] of longword; n,size,i:longint; res:extended; newel:longword; child:longint; t:longword; procedure downHeap(k,n:longint); begin newel:=m[k]; while(k<=n) do begin child:=2*k+1; if(child<n)and(m[child]<m[child+1]) then inc(child); if(newel>=m[child])or(child>n) then break; m[k]:=m[child]; k:=child; end; m[k]:=newel; end; procedure HeapSort; begin for i:=(size-1) div 2 downto 0 do downHeap(i,size-1); i:=size; while(i>0) do begin dec(i); t:=m[i]; m[i]:=m[0]; m[0]:=t; downHeap(0,i-1); end; end; begin readln(size); for i:=0 to size-1 do readln(m[i]); HeapSort; n:=size; if n mod 2=1 then begin res:=m[((n+1)div 2)-1]; write(res:0:1) end else begin res:=m[n div 2-1]; res:=res+m[n div 2]; res:=res/2; write(res:0:1); end; end. Re: Help me!!!! I have MLE!! Why Послано Saturn 25 июн 2004 13:23 Your program used 1000K(data) + 80K (program)->memory limit Re: Help me!!!! I have MLE!! Why Послано snake 28 июн 2004 20:51 What I should do to get AC |
|
|