-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11000.cpp
More file actions
29 lines (26 loc) · 516 Bytes
/
11000.cpp
File metadata and controls
29 lines (26 loc) · 516 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
void solve(){
int N; cin >> N;
pair<int,int> arr[N];
for (int i = 0; i < N; i++) {
cin >> arr[i].first >> arr[i].second;
}
sort(arr, arr+N);
priority_queue<int> pq; pq.push(-arr[0].second);
for (int i = 1; i < N; i++){
auto [a,b] = arr[i];
if (a >= -pq.top()) pq.pop();
pq.push(-b);
}
cout << pq.size();
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
solve();
return 0;
}