- 输油管道问题
- 2018-05-26 09:53:37 @
var
i,j,b,c,n,max,min:longint;
t,total:int64;
a:array[-10001..10001] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(c,b);
if b>max then max:=b;
if b<min then min:=b;
a[b]:=a[b]+1;
end;
total:=200000000000000;
for i:=min to max do
begin
for j:=min to max do
if a[j]>0 then
t:=t+a[j]*abs(i-j);
if t<total then total:=t;
end;
writeln(t);
end.
0 条评论
目前还没有评论...