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

why memlimit there's my not(AC) programm help please
Posted by Dulat_KBTU 20 Feb 2006 13:34
var
   a : array[1..250001]of longword;
   n : longint;
   t:extended;
Procedure QS(m,n : longint);
var
 i,j,w,x : longint;
BEgin
   i:=m;
   j:=n;
   x:=a[(i+j)div 2];
   while i<=j do
   if a[i]<x then inc(i)
   else if a[j]>x then dec(j)
   else
   begin
   w:=a[i];
   a[i]:=a[j];
   a[j]:=w;
   inc(i);
   dec(j);
   end;
   if m<j then qs(m,j);
   if i<n then qs(i,n);

end;
PRocedure Run;
var
i : longint;
Begin
  read(n);
  for i:=1  to n do
  read(a[i]);
  qs(1,n);
  if n mod 2 = 1 then
  begin
  t:=a[(n+1) div 2];
  writeln(t:0:1)
  end
  else
  begin
     t:=(a[n div 2+1]+a[(n div 2)]) /2;
     writeln(t:0:1);
  end;
end;
BEgin
  run;
end.
Re: why memlimit there's my not(AC) programm help please
Posted by Dulat_KBTU 20 Feb 2006 14:04
or can it be so
var
n,i,j : longint;
t,d,f : double;
begin
  read(n);
  d:=0;
  for i:=1 to n do
    begin
     read(t);
     f:=t/n;
     d:=d+f;
    end;
    writeln(d:0:1);
end.
Re: why memlimit there's my not(AC) programm help please
Posted by Ayhan Aliyev [BOTL] 20 Feb 2006 16:39
In first one you can't take array [1..25001] of longword.
Try to do it with less memory but with similar method.
Second program is wrong.