Pagini recente » Cod sursa (job #1937421) | Cod sursa (job #2765013) | Cod sursa (job #1767081) | Cod sursa (job #2149418) | Cod sursa (job #2747337)
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
priority_queue <int, vector<int>, greater<int> > pq,deleted_pq;
unordered_map<int, int> umap;
int n,i,operatie,x,nr=0;
int main ()
{
f>>n;
for(i=0;i<n;i++)
{
f>>operatie;
if(operatie==1)
{
f>>x;
pq.push(x);
nr+=1;
umap[nr]=x;
}
else if(operatie==3)
{
g<<pq.top()<<'\n';
}
else if(operatie==2)
{
f>>x;
while(pq.empty()!=1){
if(pq.top()==umap[x])
{
pq.pop();
break;
}
else{
deleted_pq.push(pq.top());
pq.pop();
}
}
while(deleted_pq.empty()!=1)
{
pq.push(deleted_pq.top());
deleted_pq.pop();
}
}
}
return 0;
}