Help,Why WA,thanks!
Послано
Bishop 7 ноя 2002 19:25
PROGRAM Ural_1207;
TYPE xl=record
key:real;
code:longint;
end;
CONST MAXN=1000;
VAR a:array[1..MAXN,1..2] of longint;
d:array[1..MAXN]of xl;
o,i,j,x,y,n:longint;
temp:xl;
BEGIN
assign(input,'T1207.in');
reset(input);
readln(n);
x:=maxlongint;
y:=maxlongint;
for i:=1 to n do
begin
readln(a[i,1],a[i,2]);
if (x>a[i,1])or((x=a[i,1])and(y>a[i,2]))then
begin
x:=a[i,1];
y:=a[i,2];
o:=i;
end;
end;
a[o,1]:=a[n,1]; a[o,2]:=a[n,2];
dec(n);
for i:=1 to n do
begin
dec(a[i,1],x);
dec(a[i,2],y);
end;
for i:=1 to n do
begin
if a[i,1]<>0 then
d[i].key:=a[i,2]/a[i,1]
else if a[i,2]<=0 then d[i].key:=-maxlongint
else d[i].key:=maxlongint;
d[i].code:=i;
end;
d[o].code:=n+1;
for i:=2 to n do
for j:=n downto i do
if d[j].key<d[j-1].key then
begin
temp:=d[j];
d[j]:=d[j-1];
d[j-1]:=temp;
end;
{if x>d[n div 2+1].code then writeln(d[n div 2+1].code,' ',o)
else} writeln(o,' ',d[n div 2+1].code);
END.