Pagini recente » Borderou de evaluare (job #2816096) | Cod sursa (job #1970273) | Cod sursa (job #899826) | Borderou de evaluare (job #3136263) | Cod sursa (job #2737171)
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
set <int> heap;
int pos[200005];
int n, operation, idx, x;
int main()
{
fin>>n;
for (int i = 1; i <= n; i++)
{
fin>>operation;
//while (!heap.empty())
//{
// cout<<*heap.begin()<<endl;
// heap.erase(*heap.begin());
//}
if (operation == 1)
{
fin>>x;
heap.insert(x);
idx += 1;
pos[idx] = x;
}
else if (operation == 2)
{
fin>>x;
heap.erase(pos[x]);
}
else fout<<*heap.begin()<<'\n';
}
return 0;
}