- 输油管道问题
- 2018-07-12 21:23:59 @
var
n,i,j,e,w,r,t,q,l:longint;
a,b,c,d:array[-10000..1000] of longint;
begin
read(n);
for i:=1 to n do
begin
read(a[i],b[i]);
if e>a[i] then e:=a[i];
if w<a[i] then w:=a[i];
if t>a[i] then t:=a[i];
if r<a[i] then r:=a[i];
end;
for i:=t to r do
for j:=e to w do
begin
for l:= 1 to n do
if a[l]=j then
if b[l]>i then c[j]:=b[l]-i
else c[j]:=i-b[l];
d[i]:=d[i]+c[j];
c[j]:=0;
end;
q:=d[t];
for i:=t+1 to r do
if (d[i]<q)and(d[i]>0) then q:=d[i];
writeln(q);
end.
0 条评论
目前还没有评论...