#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int N;
vector<pair<int, int>> V;
priority_queue<int, vector<int>, greater<int>> PQ;
int main(){
cin >> N;
int s, t;
for(int i=0; i<N; i++){
cin >> s >> t;
V.push_back({s, t});
}
sort(V.begin(), V.end());
PQ.push(V[0].second);
for(int i=1; i<N; i++){
PQ.push({V[i].second});
if(PQ.top() <= V[i].first){
PQ.pop();
}
}
cout << PQ.size() << "\n";
return 0;
}
'알고리즘' 카테고리의 다른 글
[알고리즘] 백준 10448 - 유레카 이론 (0) | 2024.08.08 |
---|---|
[알고리즘] 백준 2711 - 오타맨 고창영 (0) | 2024.08.07 |
[알고리즘] 백준 2857 - FBI (0) | 2024.08.05 |
[알고리즘] 백준 1022 - 소용돌이 예쁘게 출력하기 (0) | 2024.08.04 |
[알고리즘] 백준 2467 - 용액 (0) | 2024.08.03 |