比赛 20101110 评测结果 WWWTTTTTTT
题目名称 YL杯超级篮球赛 最终得分 0
用户昵称 ZhouZn1 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-10 19:25:28
显示代码纯文本
program zzn;
var
        i,j,n,x1,x2,y1,y2,s:longint;
        ans,minx,miny:double;
        w:array[1..90000]of longint;
        p:array[1..2,1..90000]of longint;
procedure init;
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;
        x1:=maxlongint;y1:=maxlongint;
        y2:=-maxlongint;x2:=y2;
        for i:=1 to n do
        begin
        readln(p[1,i],p[2,i]);
        if p[1,i]>x2 then x2:=p[1,i];
        if p[2,i]>y2 then y2:=p[2,i];
        if p[1,i]<x1 then x1:=p[1,i];
        if p[2,i]<y1 then y1:=p[2,i];
        end;
end;
procedure closef;
begin
        close(input);
        close(output);
end;
procedure main;
begin
        minx:=maxlongint;
        miny:=maxlongint;
        for i:=x1 to x2 do
         begin
               s:=0;
               for j:=1 to n do
                s:=s+abs(i-p[1,j]);
               if s<minx then
                minx:=s;
         end;
        for i:=y1 to y2 do
         begin
             s:=0;
             for j:=1 to n do
              s:=s+abs(i-p[2,j]);
             if s<miny then miny:=s;
         end;
        writeln((minx+miny):0:2);
end;
begin
        init;
        main;
        closef;
end.