Cod sursa(job #2895372)
| Utilizator | Data | 29 aprilie 2022 00:32:25 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <fstream>
#include <set>
#include <vector>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
set<int> heap;
vector<int> poz;
int main()
{
poz.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);
poz.push_back(x);}
else
heap.erase(poz[x]);
}
}
return 0;
}
