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 1207. Median on the Plane

why my solution can't get AC Help me please... (+)
Posted by Badd 19 Apr 2002 20:21
{My solution process by sorting the curve of point and geting the median
curve point ... thank}


const inp = '1207.in';
      maxn= 10005;
type  tdat = record xx,yy,id : longint; end;
var   fname              : text;
      dat                : array[1..maxn] of tdat;
      temp               : tdat;
      l,n,l2,min,m,mx,my,i : longint;
begin

     readln(n);
     min:=maxlongint;
     for l:=1 to n do
         begin
              readln(dat[l].xx,dat[l].yy);
              if dat[l].xx<min then
                 begin min:=dat[l].xx; m:=l; end;
              dat[l].id:=l;
         end;
     mx:=dat[m].xx; my:=dat[m].yy; i:=dat[m].id;
     for l:=1 to n-1 do
         for l2:=l+1 to n do
             if (my-dat[l2].yy)*(mx-dat[l].xx)
             >  (my-dat[l].yy) *(mx-dat[l2].xx) then
               begin
                    temp:=dat[l2];
                    dat[l2]:=dat[l];
                    dat[l]:=temp;
               end;
     for l:=1 to n do
         if (dat[l].xx=mx) and (dat[l].yy=my) then
            begin
                 if l>n div 2 then
                    writeln(i,' ',dat[n div 2].id)
                 else
                     writeln(i,' ',dat[(n div 2)+1].id);
                 halt;
            end;
end.