-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFind_the_MIN.cpp
More file actions
43 lines (38 loc) · 908 Bytes
/
Copy pathFind_the_MIN.cpp
File metadata and controls
43 lines (38 loc) · 908 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
#include <bits/stdc++.h>
using namespace std;
class cmp{
public:
bool operator()(const int& a, const int& b) const {
return a > b;
}
};
int main (){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
priority_queue<int, vector<int>, cmp> pq;
set<int> s;
while (t--) {
int command;
cin >> command;
if(command == 1){
int num;
cin >> num;
if (s.find(num) == s.end()){
pq.push(num);
s.insert(num);
}
}
else if(command == 2){
if(!pq.empty()){
int minVal = pq.top();
cout << minVal << "\n";
while (!pq.empty() && pq.top() == minVal) pq.pop();
s.erase(minVal);
}
else cout << "empty" << "\n";
}
}
return 0;
}