#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct node{
int s, t;
bool operator < (const node &a) const {
return s < a.s;
}
};
vector<node> v;
int n, ans, s, t;
int main(){
scanf("%d", &n);
for(int i = 0; i < n; ++i){
scanf("%d%d", &s, &t);
v.push_back(node{s, t});
}
sort(v.begin(), v.end());
priority_queue<int, vector<int>, greater<int> > q;
ans++;
q.push(v[0].t);
for(int i = 1; i < n; ++i){
if(q.top() > v[i].s){
ans++;
q.push(v[i].t);
}else{
q.pop();
q.push(v[i].t);
}
}
printf("%d\n", ans);
}
1428 活动安排问题
最新推荐文章于 2024-07-22 21:23:30 发布