Cod sursa(job #2774853)
Utilizator | Cristi Cretu etohirse | Data | 13 septembrie 2021 09:00:22 |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <set>
#include <fstream>
std::fstream fin("heapuri.in", std::ios::in);
std::fstream fout("heapuri.out", std::ios::out);
const int mxn = 200005;
int n, poz[mxn], idx;
std::set<int> heap;
int main(){
fin >> n;
int x, a;
for (int i = 1; i <= n; ++i) {
fin >> x;
if (x == 1) {
fin >> a;
heap.insert(a);
poz[++idx] = a;
} else if (x == 2) {
fin >> a;
heap.erase(poz[a]);
} else {
fout << *heap.begin() << '\n';
}
}
return 0;
}