区间数组
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; int n; struct Range{ int l,r; bool operator<(const Range & w)const { return l<w.l; } }range[N]; int main(){ cin>>n; for(int i=0;i<n;i++){ int l,r; cin>>l>>r; range[i]={l,r}; } sort(range,range+n); priority_queue<int,vector<int>,greater<int>> heap; for (int i = 0; i < n; i ++ ) { auto r = range[i]; if (heap.empty() || heap.top() >= r.l) heap.push(r.r); else { heap.pop(); heap.push(r.r); } } cout<<heap.size()<<endl; return 0; }