题目描述
blablabla
样例
blablabla
和poj3190类似
https://blog.csdn.net/z309241990/article/details/19566625
C++ 代码
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 100010;
struct Node
{
int l, r;
bool operator< (const Node &W)const
{
return l < W.l;
}
}node[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i ++ )
{
int l, r;
scanf("%d%d", &l, &r);
node[i] = {l, r};
}
sort(node, node + n);
priority_queue<int, vector<int>, greater<int>> heap;
heap.push(node[0].r);
for (int i = 1; i < n; ++i) {
if(node[i].l>heap.top()){
heap.pop();
heap.push(node[i].r);
}else{
heap.push(node[i].r);
}
}
cout<<heap.size()<<endl;
return 0;
}