不是VIP会员,不能显示答案

题目解答

题目:
var
n,i,j,t,ans:longint;
x,y:array[0..500] of longint;
begin
readln(n);
for i:=1 to n do
readln(x[i],y[i]);
for i:=1 to n-1 do
for j:=1 to n-i do
begin
if x[j]>x[j+1] then
begin
t:=x[j];
x[j]:=x[j+1];
x[j+1]:=t;
end;
if y[j]>y[j+1] then
begin
t:=y[j];
y[j]:=y[j+1];
y[j+1]:=t;
end;
end;
ans:=0;
for i:=1 to n do
ans:=ans+abs(i-x[i])+abs(i-y[i]);
writeln(ans);
end.
输入:
6
1 1
1 2
2 1
5 6
6 5
6 6

输出:8
考点:
分析:
解答:
评论:
老师: