Pagini recente » Cod sursa (job #2957623) | Cod sursa (job #779164) | Cod sursa (job #1935312) | Cod sursa (job #2769959) | Cod sursa (job #2737167)
#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()<<endl;
}
return 0;
}