ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1306. Sequence Median

I not understand why WA #5!!! plz help
Posted by Tolstobrov_Anatoliy[Ivanovo SPU] 7 Jun 2005 02:15


{$N+}
const coll=250000;
var n,i,j:longint;
m:array[0..coll] of double;


procedure Go(li,ls:longint);
var
  i,j:longint;
  x,y:double;
begin
i:=li;
j:=ls;
x:=m[(li+ls) div 2];

repeat
while m[i]<x do inc(i);
while m[j]>x do dec(j);

 if i<=j then
      begin
        x:=m[i];
        m[i]:=m[j];
        m[j]:=x;
        inc(i);
        dec(j);
      end;

until i>j;

if i<ls then Go(i,ls);
if j>li then Go(li,j);

end;

begin
readln(n);
for i:=1 to n do readln(m[i]);
Go(1,n);

if n=1 then writeln(m[1]:1:1)
   else if n mod 2=1 then writeln(m[n div 2+1]:1:1)
   else writeln((m[n div 2]+m[n div 2+1])/2:1:1);
end.


help plz
Re: I not understand why WA #5!!! plz help
Posted by KingPin 7 Jun 2005 04:36
1. Use writeln(x:0:1) instead of writeln(x:1:1)

2. You will get Memory Limit Exceeded. All troubles are memory related in this particular problem.