Pagini recente » Cod sursa (job #2773279) | Cod sursa (job #133264) | Cod sursa (job #2925582) | Cod sursa (job #3143453) | Cod sursa (job #2737162)
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
set <int> heap;
int pos[200001];
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;
}