比赛 20101110 评测结果 TTTTTTTEEE
题目名称 YL杯超级篮球赛 最终得分 0
用户昵称 1102 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-10 19:39:54
显示代码纯文本
program xxx;
var n,i,j,k:longint;
    a:array[1..10000,0..2] of real;
    f:array[0..1000,0..1000,1..4] of real;
    w:real;

function min(a1,a2,a3,a4,a5:real):real;
var x:real;
begin
  x:=200000000;
  if a1<x then x:=a1;
  if a2<x then x:=a2;
  if a3<x then x:=a3;
  if a4<x then x:=a4;
  if a5<x then x:=a5;
  min:=x;
end;


begin
  assign(input,'ballc.in');
  reset(input);
  assign(output,'ballc.out');
  rewrite(output);
  read(n);
  for i:=1 to n do
    read(a[i,0]);
  for i:=1 to n do
    read(a[i,1],a[i,2]);
  w:=200000000;
  for i:=0 to 1000 do
    for j:=0 to 1000 do
      begin
        for k:=1 to n do
          begin
            f[i,j,1]:=f[i,j,1]+a[k,0]*(abs(i-a[k,1])+abs(j-a[k,2]));
            f[i,j,2]:=f[i,j,2]+a[k,0]*(abs(i-a[k,1])+abs(-j-a[k,2]));
            f[i,j,3]:=f[i,j,3]+a[k,0]*(abs(-i-a[k,1])+abs(j-a[k,2]));
            f[i,j,4]:=f[i,j,4]+a[k,0]*(abs(-i-a[k,1])+abs(-j-a[k,2]));
          end;
        w:=min(f[i,j,1],f[i,j,2],f[i,j,3],f[i,j,4],w);
        if (f[i,j,1]=0)or(f[i,j,2]=0)or(f[i,j,3]=0)or(f[i,j,4]=0) then
          begin
            write('0.00');
            close(input);
            close(output);
            halt;
          end;
      end;
  write(w:0:2);
  close(input);
  close(output);
end.