- 校门外的树
- 2014-08-06 21:46:41 @
var
a:array[1..100,1..2] of longint;
n,m,i,x,y,j,k:longint;
begin
readln(n,m);
for i:=1 to m do
begin
readln(a[i,1],a[i,2]);
end;
for k:=1 to m-1 do
begin
for i:=1 to m-k do
begin
if a[i,1]>a[i+1,1]
then
begin
j:=a[i,1];
a[i,1]:=a[i+1,1];
a[i+1,1]:=j;
j:=a[i,2];
a[i,2]:=a[i+1,2];
a[i+1,2]:=j;
end;
end;
end;
for i:=1 to m do
begin
x:=x+(a[i,2]-a[i,1])+1;
end;
for i:=1 to m-1 do
begin
if a[i+1,1]<a[i,2]
then
begin
y:=y+(a[i,2]-a[i+1,1])+1;
end;
end;
n:=n+1-x+y;
write(n);
end.
0 条评论
目前还没有评论...