Mai intai trebuie sa te autentifici.
Cod sursa(job #2895300)
| Utilizator | Data | 28 aprilie 2022 21:53:18 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <fstream>
#include <set>
#include <vector>
std::set<int> heap;
std::vector<int> ordine;
int main()
{
std::ifstream fin("heapuri.in");
std::ofstream fout("heapuri.out");
ordine.push_back(-1);
int n;
fin >> n;
for (int i = 0; i < n; ++i) {
int op;
fin >> op;
if (op == 3) fout << *heap.begin() << '\n';
else {
int x;
fin >> x;
if (op == 1) heap.insert(x), ordine.push_back(x);
else heap.erase(ordine[x]), ordine.erase(ordine.begin() + x - 1);
}
}
return 0;
}