Cod sursa(job #2757224)
| Utilizator | Data | 4 iunie 2021 16:34:46 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
int main()
{
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
int N;
multiset<int> heap;
vector<int> history;
scanf("%d", &N);
int op, x;
for (int i = 0; i < N; ++i) {
scanf("%d", &op);
if (op == 1) {
scanf("%d", &x);
history.emplace_back(x);
heap.insert(x);
continue;
}
if (op == 2) {
scanf("%d", &x);
heap.erase(history[x-1]);
continue;
}
printf("%d\n", *heap.begin());
}
return 0;
}
