-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeForces-1468C.cpp
More file actions
44 lines (40 loc) · 1.02 KB
/
CodeForces-1468C.cpp
File metadata and controls
44 lines (40 loc) · 1.02 KB
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
//
// Created by abdob on 10/23/2022.
//
#include <cstdio>
#include <set>
#include <map>
int main(){
const long N = 1e9;
std::set<long> s;
std::set<std::pair<long, long> > t;
std::map<long, long> r;
long q; scanf("%ld", &q);
long cnt(0);
while(q--){
long w; scanf("%ld", &w);
if(w == 1){
++cnt;
long m; scanf("%ld", &m);
s.insert(cnt);
t.insert(std::make_pair(m, N - cnt));
r[cnt] = m;
}
else if(w == 2){
long num = *(s.begin());
printf("%ld ", num);
s.erase(num);
t.erase(std::make_pair(r[num], N - num));
r.erase(num);
}
else if(w == 3){
std::pair<long, long> cust = *t.rbegin();
long num = N - cust.second; long spend = cust.first;
printf("%ld ", num);
s.erase(num);
t.erase(cust);
r.erase(num);
}
}
puts("");
}