Cod sursa(job #554044)
#include<fstream>
#include<set>
#include<vector>
using namespace std;
int op,x,cont=1;
int N;
vector<int> v;
set< pair<int,int> > heap;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
inline void verif()
{
in>>op;
if(op==3)
{
set< pair<int,int> >::iterator it=heap.begin();
out<<it->first<<"\n";
return;
}
in>>x;
if(op==1)
{
heap.insert(make_pair(x,cont++));
v.push_back(x);
return;
}
if(op==2)
{
set< pair<int,int> >::iterator it=heap.find(make_pair(v[x],x));
heap.erase(it);
}
}
int main()
{
in>>N;
v.push_back(0);
for(int i=1;i<=N;i++)
{
verif();
}
return 0;
}