记录编号 |
22387 |
评测结果 |
AAAAAAAAAA |
题目名称 |
YL杯超级篮球赛 |
最终得分 |
100 |
用户昵称 |
郭乾乐 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.509 s |
提交时间 |
2010-11-18 22:10:48 |
内存使用 |
1.73 MiB |
显示代码纯文本
program mwt;
var
ans:extended;
a:array[0..50000,1..2]of extended;
key:array[1..50000]of longint;
w:array[1..50000]of extended;
n,i:longint;
procedure sort(l,r,lab:longint);
var
i,j,x,t:longint;
begin
if l>=r then exit;
i:=l;j:=r;
x:=key[(l+r)shr 1];
repeat
while a[key[i],lab]<a[x,lab] do
i:=i+1;
while a[key[j],lab]>a[x,lab] do
j:=j-1;
if i<=j then
begin
t:=key[i];key[i]:=key[j];key[j]:=t;
i:=i+1;j:=j-1;
end;
until i>j;
sort(l,j,lab);
sort(i,r,lab);
end;
procedure jie(x:longint);
var
i:longint;
l,r,sl,sr,min:extended;
begin
for i:=1 to n do
key[i]:=i;
sort(1,n,x);
l:=0;r:=0;
sl:=0;sr:=0;
for i:=2 to n do
begin
sr:=sr+w[key[i]];
r:=r+(a[key[i],x]-a[key[1],x])*w[key[i]];
end;
min:=r;
for i:=2 to n do
begin
sl:=sl+w[key[i-1]];
l:=l+sl*(a[key[i],x]-a[key[i-1],x]);
r:=r-sr*(a[key[i],x]-a[key[i-1],x]);
sr:=sr-w[key[i]];
if l+r<min then min:=l+r;
end;
ans:=ans+min;
end;
begin
assign(input,'ballc.in');
reset(input);
assign(output,'ballc.out');
rewrite(output);
readln(n);
for i:=1 to n do
read(w[i]);
for i:=1 to n do
readln(a[i,1],a[i,2]);
ans:=0;
jie(1);
jie(2);
write(ans:0:2);
close(input);
close(output);
end.