Pagini recente » Cod sursa (job #1072154) | Borderou de evaluare (job #1761569) | Cod sursa (job #3125031) | Cod sursa (job #2751659) | Cod sursa (job #3168370)
#include <fstream>
#include <queue>
using namespace std;
ifstream cin("heapuri.in");
ofstream cout("heapuri.out");
struct elem{
int poz, val;
bool operator<(const elem &other)const
{
return val>other.val;
}
};
priority_queue <elem> heap;
int to_pop[200005];
int main()
{
int n,k=1;
cin>>n;
for(int i=1;i<=n;i++)
{
int c,x;
cin>>c;
if(c==1)
{
cin>>x;
elem e;
e.val=x;
e.poz=k;
k++;
heap.push(e);
}
if(c==2)
{
cin>>x;
to_pop[x]=1;
}
if(c==3)
{
elem e=heap.top();
while(to_pop[e.poz]==1)
{
heap.pop();
e=heap.top();
}
cout<<heap.top().val<<'\n';
}
}
return 0;
}