#include <bits/stdc++.h>
#define PII pair<int, int>
using namespace std;
const int maxn = 100000 + 5;
PII a[maxn];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i ++)
{
cin >> a[i].first >> a[i].second;
}
sort(a, a + n);
int cnt = n;
for (int i = 0; i < n - 1; i ++)
{
if (a[i + 1].first <= a[i].second)
{
cnt --;
a[i + 1].first = a[i].first;
a[i + 1].second = max(a[i].second, a[i + 1].second);
}
}
cout << cnt;
return 0;
}
C++区间合并
最新推荐文章于 2024-05-11 16:13:07 发布