作者:
MyPower
,
2023-05-09 20:58:13
,
所有人可见
,
阅读 7
#include <iostream>
#include <algorithm>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 100010;
PII q[N];
bool cmp(PII a, PII b)
{
return a.y < b.y;
}
int main()
{
int n;
scanf("%d", &n);
int a, b;
for(int i = 0; i < n; i ++)
{
cin >> a >> b;
q[i].x = a;
q[i].y = b;
// cout << q[i].x << " " << q[i].y << endl;
}
sort(q, q + n, cmp);
int ans = 0, t = 9e9;
for(int i = 0; i < n; i ++)
{
// cout << t << endl;
if(t >= q[i].x && t <= q[i].y) continue;
else
{
t = q[i].y;
ans ++;
}
}
printf("%d", ans);
}