O(n log n)将结束时间或开始时间排序都可以,在另外一条序列中选择上一场比赛和下一场比赛开始时间不冲突的比赛加入。var n:longint; a,b:array[1..2000000] of longint;PRocedure qsort(l,r:longint);var i,j,m,t:longint;begin i:=l;j:=r; m:=b[(l+r)div 2]; repeat while b[i]<m do inc(i); while b[j]>m do dec(j); if i<=j then begin t:=a[i];a[i]:=a[j];a[j]:=t; t:=b[i];b[i]:=b[j];b[j]:=t; inc(i);dec(j); end; until i>j; if i<r then qsort(i,r); if l<j then qsort(l,j);end;var i,ans,sum:longint;begin readln(n); for i:=1 to n do readln(a[i],b[i]); qsort(1,n); ans:=b[1]; for i:=2 to n do if a[i]>=ans then begin inc(sum); ans:=b[i]; end; writeln(sum+1);end.