Cod sursa(job #2761742)
| Utilizator | Data | 3 iulie 2021 20:35:17 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include<iostream>
#include<fstream>
#include <set>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int main() {
set<int>heap;
int v[200010] = { 0 };
int n;
f >> n;
int comanda, x;
int k = 0;
for (int i = 0; i < n; i++) {
f >> comanda;
if (comanda == 1) {
f >> x;
k++;
v[k] = x;
heap.insert(x);
}
if (comanda == 2) {
f >> x;
heap.erase(v[x]);
}
if (comanda == 3) {
g << *heap.begin() << endl;
}
}
f.close();
g.close();
return 0;
}
