#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
constexpr int N = 1e6 + 10, inf = 0x3f3f3f3f;
int a[N];
#define x first
#define y second
typedef pair<int, int> pii;
pii pre[N];
bool cmp(pii a, pii b)
{
return a.y < b.y;
}
void solve()
{
int n;
cin >> n;
rep(i, 1, n)
{
cin >> pre[i].x >> pre[i].y;
}
sort(pre + 1, pre + n + 1, cmp);
int now = pre[1].y;
int res = 1;
for (int i = 1; i <= n; i++)
{
if (now < pre[i].x || now > pre[i].y)
{
res++;
now = pre[i].y;
}
}
cout << res << endl;
}
signed main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
while (T--)
{
solve();
}
return 0;
}
11-13
3453
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-22
725
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)