Pagini recente » Cod sursa (job #2914061) | Cod sursa (job #1418537) | Cod sursa (job #846935) | Cod sursa (job #1627643) | Cod sursa (job #2896385)
#include <iostream>
#include <queue>
#include <fstream>
using namespace std;
const int Max=200005;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int N; bool inheap[Max];
priority_queue < pair <int,int > ,vector < pair < int,int > > , greater <pair <int,int > > >pq;
int main()
{
fin>>N; int val=0,x,operatie;
for(int i=1;i<=N;i++)
{
fin>>operatie;
if(operatie==1 || operatie==2)
fin>>x;
if(operatie==1)
pq.push({x,++val});
else if(operatie==2)
inheap[x]=1;
else
{
while(inheap[pq.top().second])
pq.pop();
fout<<pq.top().first<<"\n";
}
}
fin.close();
fout.close();
return 0;
}