Cod sursa(job #2721182)
| Utilizator | Data | 11 martie 2021 16:59:08 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <fstream>
#include <set>
#define NMAX 200000
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int q, k, a[NMAX+10];
multiset <int> S;
int main()
{
fin >> q;
while(q--)
{ int type;
fin >> type;
if(type == 1)
{ int x;
fin >> x;
a[++k] = x;
S.insert(x);
}
else if(type == 2)
{ int x;
fin >> x;
multiset <int>::iterator it = S.lower_bound(a[x]);
S.erase(it);
}
else
fout << *S.begin() << '\n';
}
return 0;
}