Pagini recente » Cod sursa (job #683684) | Cod sursa (job #1607979) | Cod sursa (job #1034778) | Cod sursa (job #1360145) | Cod sursa (job #1244548)
#include<fstream>
#include<queue>
using namespace std;
ifstream fin( "heapuri.in" );
ofstream fout( "heapuri.out" );
const int nmax = 200000;
const int inf = 1 << 30;
int v[ nmax + 1 ];
struct cmp {
bool operator()( int x, int y ) {
return v[ x ] > v[ y ];
}
};
priority_queue <int, vector<int>, cmp> h;
int main() {
int n, t, ii, x;
fin >> n;
ii = 0;
for( int i = 0; i < n; ++ i ) {
fin >> t;
if ( t == 3 ) {
while ( v[ h.top() ] == inf ) {
h.pop();
}
fout << v[ h.top() ] << "\n";
} else if ( t == 1 ) {
fin >> v[ ii ];
h.push( ii );
++ ii;
} else {
fin >> x;
v[ x - 1 ] = inf;
}
}
fin.close();
fout.close();
return 0;
}