-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11000.cpp
More file actions
44 lines (38 loc) · 756 Bytes
/
11000.cpp
File metadata and controls
44 lines (38 loc) · 756 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int n;
struct room {
int s,t;
};
room arr[200001];
bool cmp(room a, room b) {
if(a.s==b.s) {
return a.t < b.t;
}
return a.s < b.s;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for(int i=0 ; i<n ; i++) {
cin >> arr[i].s >> arr[i].t;
}
sort(arr, arr+n, cmp);
priority_queue<int, vector<int>, greater<int>> q;
q.push(arr[0].t);
for(int i=1 ; i<n ; i++) {
int s = arr[i].s, t = arr[i].t;
int now = q.top();
if(now>s) {
q.push(t);
} else {
q.pop();
q.push(t);
}
}
cout << q.size();
return 0;
}