Cod sursa(job #2805869)
| Utilizator | Data | 22 noiembrie 2021 02:53:23 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include <fstream>
#include <set>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
multiset <int> q;
multiset <int> ::iterator it;
int v[200002];
int main()
{
int n, c, x, nr = 0;
f >> n;
while (n--)
{
f >> c;
if (c == 1)
{
f >> x;
++nr;
v[nr] = x;
q.insert(x);
}
else
{
if (c == 2)
{
f >> x;
q.erase(v[x]);
}
else
{
it = q.begin();
g << *it << '\n';
}
}
}
return 0;
}