Cod sursa(job #2895369)
| Utilizator | Data | 29 aprilie 2022 00:27:41 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.68 kb |
#include <vector>
#include <set>
#include <fstream>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
vector <int> poz;
set <int> heap;
int main()
{
poz.push_back(-1);
int N, x;
fin >> N;
for(long i = 0; i < N; i++)
{
int op;
fin >> op;
if(op == 1) {
fin >> x;
heap.insert(x);
poz.push_back(x);
}
if(op == 2)
{
fin >> x;
heap.erase(poz[x-1]);
}
if(op == 3)
{
int first = *heap.begin();
fout << first <<'\n';
}
}
return 0;
}
