-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11000.cpp
More file actions
48 lines (36 loc) · 664 Bytes
/
11000.cpp
File metadata and controls
48 lines (36 loc) · 664 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
45
46
47
48
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <functional>
using namespace std;
int main() {
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
priority_queue<int, vector<int>, greater<int>>q;
int res = 1;
int N;
vector<pair<int,int>>v;
vector<int>idx;
cin >> N;
while (N--) {
int a, b;
cin >> a >> b;
v.push_back({ a,b });
}
q.push(v[0].second);
for (int i = 1;i < v.size();i++) {
if (q.top() > v[i].first)
{
q.push(v[i].second);
}
else if(q.top()<=v[i].first) {
q.pop();
q.push(v[i].second);
}
}
cout << q.size() << "\n";
return 0;
}