区间分组
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 100010;
int n;
struct Range
{
int l, r;
bool operator< (const Range &W)
{
return l < W.l;
}
} ranges[N];
int main()
{
cin >> n;
for(int i = 0; i < n; i ++ )
{
int l, r;
cin >> l >> r;
ranges[i] = {l, r};
}
sort(ranges, ranges + n);
priority_queue<int, vector<int>, greater<int>> heap;
for(int i = 0; i < n; i ++ )
{
auto r = ranges[i];
if(heap.empty() || heap.top() >= r.l) heap.push(r.r);
else
{
int t = heap.top();
heap.pop();
heap.push(r.r);
}
}
printf("%d\n", heap.size());
return 0;
}