-
Notifications
You must be signed in to change notification settings - Fork 3
/
a.cpp
55 lines (50 loc) · 964 Bytes
/
a.cpp
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
49
50
51
52
53
54
55
/**
* @date 2022-03-28
* @tags data structure, implementation
* @difficulty 1500
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pair = pair<ll,string>;
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL); // Fast IO
int N;
ll K;
cin >> N >> K;
unordered_set<string> S;
priority_queue<Pair,vector<Pair>,greater<Pair>> pq;
auto query = [&]() -> string {
while (!pq.empty()) {
auto [p, m] = pq.top(); pq.pop();
if (!S.count(m)) continue;
return m;
}
return "doctor takes a break";
};
while (N--) {
int Q,T;
cin >> Q >> T;
switch (Q) {
case 1: {
string M;
ll s;
cin >> M >> s;
S.insert(M);
pq.emplace(-(s-T*K), move(M));
break;
}
case 2: {
cout << query() << endl;
break;
}
case 3: {
string M;
cin >> M;
S.erase(M);
break;
}
}
}
return 0;
}