Pagini recente » Cod sursa (job #3253912) | Cod sursa (job #1811861) | Cod sursa (job #2892856) | Cod sursa (job #382352) | Cod sursa (job #2750091)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
priority_queue <pair <int,int> ,vector <pair <int,int>>,greater <pair <int,int>>> h;
int n,t,x;
bitset <200005> elim;
int main()
{
fin>>n;
int i;
int cnt=0;
for(i=1; i<=n; i++)
{
fin>>t;
if(t==1)
{
fin>>x;
cnt++;
h.push(make_pair(x,cnt));
}
else if(t==2)
{
fin>>x;
elim[x]=1;
}
else
{
while(!h.empty() && elim[h.top().second])
h.pop();
fout<<h.top().first<<"\n";
}
}
return 0;
}