Pagini recente » Cod sursa (job #2310788) | Cod sursa (job #840889) | Cod sursa (job #66557) | Cod sursa (job #126305) | Cod sursa (job #2272329)
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
const int Nmax=2e5+10;
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > heap;
int n,i,p,x,cnt;
bool used[Nmax];
int main()
{
f>>n;
for(i=1;i<=n;i++)
{
f>>p;
if(p==1)
{
f>>x;
cnt++;
heap.push({x,cnt});
}
else if(p==2)
{
f>>x;
used[x]=true;
}
else {
while(!heap.empty()&&used[heap.top().second])
heap.pop();
g<<heap.top().first<<'\n';
}
}
return 0;
}