比赛 20101110 评测结果 TTTTTTTTTT
题目名称 YL杯超级篮球赛 最终得分 0
用户昵称 苏轼 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-10 20:56:30
显示代码纯文本
program ballc(input,output);

label nonono;

type
  re=record
    x,y:longint;
  end;

var
  n,i,j,k:longint;
  sum,best:double;
  min,max:re;
  co:array[1..100]of re;
  w:array[1..100]of longint;

begin
  assign(input,'ballc.in');
  reset(input);
  assign(output,'ballc.out');
  rewrite(output);

  readln(n);
  for i:=1 to n do
    read(w[i]);
  readln;

  min.x:=maxint;
  min.y:=maxint;
  max.x:=0;
  max.y:=0;
  for i:=1 to n do
  begin
    readln(co[i].x,co[i].y);

    if co[i].x<min.x then
      min.x:=co[i].x;
    if co[i].y<min.y then
      min.y:=co[i].y;

    if co[i].x>max.x then
      max.x:=co[i].x;
    if co[i].y>min.y then
      max.y:=co[i].y;
  end;

  best:=maxlongint;
  for i:=min.x to max.x do
    for j:=min.y to max.y do
    begin
      sum:=0;
      for k:=1 to n do
      begin
        sum:=sum+w[k]*(abs(i-co[k].x)+abs(j-co[k].y));

        if sum>best then
          goto nonono;
      end;

      best:=sum;
nonono:;
    end;

  writeln(best:0:2);

  close(input);
  close(output);
end.