比赛 20101110 评测结果 TTTTTTTTTT
题目名称 YL杯超级篮球赛 最终得分 0
用户昵称 donny 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-10 20:49:14
显示代码纯文本
program ballc;
var
  w:array[1..100000]of real;
  a:array[1..100000,1..2]of longint;
  i,j,k:longint;
  n:longint;
  o,q:real;
  l,r,s,t: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;
  l:=10000000;
  r:=-10000000;
  s:=10000000;
  t:=-10000000;
  for i:=1 to n do
  begin
    readln(a[i,1],a[i,2]);
    if a[i,1]<l then l:=a[i,1];
    if a[i,1]>r then r:=a[i,1];
    if a[i,2]<s then s:=a[i,2];
    if a[i,2]>t then t:=a[i,2];
  end;
  q:=1000000000;
  for i:=l to r do
    for j:=s to t do
    begin
      o:=0;
      for k:=1 to n do
        o:=o+w[k]*(abs(a[k,1]-i)+abs(a[k,2]-j));
      if o<q then q:=o;
    end;
  writeln(q:0:2);
  close(input);
  close(output);
end.