#include<iostream>
#include<algorithm>
using namespace std;
struct Point {
int frist, second;
} a[1000000];
bool cmp(struct Point b, struct Point c) {
if(b.second < c.second)
return true;
else
return false;
}
int main() {
int i, j, n, m, T = 0, num = 0;
cin >> n;
for(i = 0; i < n; i++)
cin >> a[i].frist >> a[i].second;
sort(a, a + n, cmp);
for(i = 0; i < n; i++) {
if(T <= a[i].frist) {
T = a[i].second;
num++;
}
}
cout << num;
}
思路是每次选择结束最快的;