Cod sursa(job #2761399)
| Utilizator | Data | 2 iulie 2021 02:13:39 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.7 kb |
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
set <int> heap;
vector <int> aux;
void add (int x)
{
heap.insert(x);
aux.push_back(x);
}
void sterge (int poz)
{
heap.erase(aux[poz-1]);
}
void afisMin ()
{
cout<<*heap.begin()<<"\n";
}
int main()
{
int op, nrop, x;
f>>nrop;
for(int i = 0; i < nrop; i++)
{
f>>op;
if(op == 1)
{
f>>x;
add(x);
}
if (op == 2)
{
f>>x;
sterge(x);
}
if(op == 3)
afisMin();
}
return 0;
}
