Pagini recente » Cod sursa (job #2104920) | Cod sursa (job #1289138) | Cod sursa (job #770242) | Cod sursa (job #2104857) | Cod sursa (job #1921132)
#include<bits/stdc++.h>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
const int N_MAX = 2e5 + 2;
bool deleteElement[N_MAX];
priority_queue< pair<int, int>, vector<pair <int, int> >, greater< pair<int, int> > > Q;
int main()
{
int N, test, x, l;
in >> N;
l = 0;
while( N-- )
{
in >> test;
if( test == 1 ){
in >> x;
l ++;
Q.push({x, l});
}else{
if( test == 2 )
{
in >> x;
deleteElement[x] = 1;
}else{
while( deleteElement[ Q.top().second ] ) Q.pop();
out << Q.top().first <<"\n";
}
}
}
return 0;
}