Cod sursa(job #2746331)
Utilizator | Data | 27 aprilie 2021 18:16:09 | |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.62 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in ("heapuri.in");
ofstream out ("heapuri.out");
set<int> heap;
vector<int> v;
int n, operatie, nr, poz;
int main()
{
in>>n;
for(int i=0; i<n; i++)
{
in>>operatie;
if (operatie==1)
{
in >> nr;
heap.insert(nr);
v.push_back(nr);
}
else
if (operatie==2)
{
in >> poz;
heap.erase(v[poz-1]);
}
else
if (operatie==3)
{
out << *heap.begin() << '\n';
}
}
return 0;
}