比赛 “Asm.Def战记之拉格朗日点”杯 评测结果 AAAAAAAAAA
题目名称 Asm.Def找燃料 最终得分 100
用户昵称 Derrick_M 运行时间 0.033 s
代码语言 Pascal 内存使用 0.13 MiB
提交时间 2015-11-04 08:46:48
显示代码纯文本
program P2090;
const
  eps=0.0000000001;
var
  a,b,a0,b0,c:array[1..100] of longint;
  i,j,k,n,ans,sum,cnt:longint;

procedure swap(var u,v:longint);
var
  tmp:longint;
begin
  tmp:=u;
  u:=v;
  v:=tmp;
end;

procedure qsort(l,r:longint);
var
  i,j,x,y,m:longint;
begin
  i:=l;
  j:=r;
  m:=l+random(r-l+1);
  x:=a[m];
  y:=b[m];
  repeat
    while (a[i]<x) or ((a[i]=x) and (b[i]<y)) do inc(i);
    while (x<a[j]) or ((x=a[j]) and (y<b[j])) do dec(j);
    if not(i>j) then
                begin
                  swap(a[i],a[j]);
                  swap(b[i],b[j]);
                  inc(i);
                  j:=j-1;
                end;
  until i>j;
  if l<j then qsort(l,j);
  if i<r then qsort(i,r);
end;

begin
  assign(input,'asm_fuel.in');assign(output,'asm_fuel.out');
  reset(input);rewrite(output);
  randomize;
  readln(n);
  for i:=1 to n do
    readln(a[i],b[i]);
  qsort(1,n);
  cnt:=1;
  a0[1]:=a[1];
  b0[1]:=b[1];
  c[1]:=1;
  for i:=2 to n do
    if (a[i]<>a[i-1]) or (b[i]<>b[i-1]) then
    begin
      inc(cnt);
      a0[cnt]:=a[i];
      b0[cnt]:=b[i];
      c[cnt]:=1;
    end
    else inc(c[cnt]);
  ans:=1;
  for i:=1 to cnt do
    for j:=i+1 to cnt do
      if a0[i]=a0[j] then
      begin
        sum:=c[i]+c[j];
        for k:=j+1 to cnt do
          if a0[k]=a0[i] then inc(sum,c[k])
                         else break;
        if sum>ans then ans:=sum;
      end
      else
      begin
        sum:=c[i]+c[j];
        for k:=j+1 to cnt do
        begin
          if a0[k]=a0[j] then continue;
          if abs((b0[k]-b0[j])/(a0[k]-a0[j])-
                 (b0[j]-b0[i])/(a0[j]-a0[i]))<eps then inc(sum,c[k]);
        end;
        if sum>ans then ans:=sum;
      end;
  writeln(ans);
  close(input);close(output);
end.