Cod sursa(job #3124215)
| Utilizator | Data | 27 aprilie 2023 11:33:30 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
std::ifstream f("heapuri.in");
std::ofstream g("heapuri.out");
std::set<int> heap;
std::vector <int> v;
int main()
{
int n, operatie, x;
f >> n;
for (int i = 0; i < n; i++)
{
f >> operatie;
if (operatie == 1)
{
f >> x;
heap.insert(x);
v.push_back(x);
}
else if (operatie == 2)
{
f >> x;
heap.erase(v[x - 1]);
}
else
{
g << *heap.begin() << "\n";
}
}
}