比赛 20091026 评测结果 WWWTWWTTTA
题目名称 抗震救灾 最终得分 10
用户昵称 ybh 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-10-26 21:58:32
显示代码纯文本
program savez;
type
  ty=array[1..60] of byte;
var
  a1,a2:array[1..5000] of ty;
  a3:array[1..5000] of string;
  bool:boolean;
  st,st1:string;
  s,i,j,j1,code,j2,min1:integer;
  he,cha,ji,min:ty;

procedure add(a,b:ty;var c:ty);
var
  i1:integer;
begin
  fillchar(c,sizeof(c),0);
  for i1:=1 to 60 do
  begin
    c[i1]:=c[i1]+a[i1]+b[i1];
    if c[i1]>=10 then
    begin
      c[i1+1]:=c[i1] div 10;
      c[i1]:=c[i1] mod 10
    end
  end
end;

procedure mul(a,b:ty;var c:ty);
var
  i1,j1:integer;
begin
  fillchar(c,sizeof(c),0);
  for i1:=1 to 60 do
    for j1:=1 to 60 do
      c[i1+j1]:=c[i1+j1]+a[i1]*b[j1];
  for i1:=2 to 60 do
    if c[i1]>9 then
    begin
      c[i1+1]:=c[i1+1]+(c[i1] div 10);
      c[i1]:=c[i1] mod 10
    end;
end;

procedure sub(a,b:ty;var c:ty);
var
  i1:integer;
begin
  fillchar(c,sizeof(c),0);
  for i1:=1 to 60 do
    if a[i1]>=b[i1] then
    begin
      c[i1]:=a[i1]-b[i1]
    end
    else
    begin
      a[i1+1]:=a[i1+1]-1;
      c[i1]:=a[i1]+10-b[i1]
    end;
end;

begin
  assign(input,'savez.in');
  reset(input);
  assign(output,'savez.out');
  rewrite(output);
  bool:=false;
  s:=0;
  repeat
    readln(st);
    if st<>'' then
    begin
      s:=s+1;
      for i:=1 to 3 do
        if st[i+1]=' ' then
        begin
          st1:=copy(st,1,i);
          j1:=0;
          for j:=length(st1) downto 1 do
          begin
            j1:=j1+1;
            val(copy(st1,j,1),a1[s,j1],code)
          end;
          break
        end;
      delete(st,1,i+1);
      for i:=1 to length(st) do
        if st[i+1]=' ' then
        begin
          st1:=copy(st,1,i);
          j1:=0;
          for j:=length(st1) downto 1 do
          begin
            j1:=j1+1;
            val(copy(st1,j,1),a2[s,j1],code)
          end;
          break
        end;
      delete(st,1,i+1);
      a3[s]:=st
    end
    else
      bool:=true;
  until bool;
  fillchar(min,sizeof(min),9);
  for i:=1 to s do
  begin
    fillchar(he,sizeof(he),0);
    for j:=1 to s do
    begin
      if i=j
        then continue;
      fillchar(cha,sizeof(cha),0);
      fillchar(ji,sizeof(ji),0);
      for j2:=60 downto 1 do
      begin
        if a2[i,j2]<a2[j,j2] then
        begin
          sub(a2[j],a2[i],cha);
          break
        end;
        if a2[i,j2]>a2[j,j2] then
        begin
          sub(a2[i],a2[j],cha);
          break
        end;
      end;
      mul(cha,a1[j],ji);
      add(he,ji,he)
    end;
    for j:=60 downto 1 do
    begin
      if he[j]<min[j] then
      begin
        min:=he;
        min1:=i;
        break
      end;
      if he[j]>min[j] then
      begin
        break
      end;
    end;
  end;
  writeln(a3[min1]);
  close(input);
  close(output)
end.