Pagini recente » Cod sursa (job #2676395) | Cod sursa (job #2210610) | Cod sursa (job #2367440) | Cod sursa (job #2923722) | Cod sursa (job #2876404)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
priority_queue < int > heap;
int n;
bool deSters[200000];
int main()
{
ifstream f("heapuri.in");
ofstream g("heapuri.out");
f >> n;
int v[n], k = 0;
for( int i = 0; i < n; ++i )
{
int op;
f >> op;
if( op == 1 || op == 2 )
{
int x;
f >> x;
if( op == 1 )
{
heap.push( -x );
v[k++] = -x;
}
else if( op == 2 )
{
deSters[ v[x - 1] ] = true;
while( deSters[ heap.top() ] )
heap.pop();
}
}
else
g << -heap.top() << endl;
}
f.close();
g.close();
return 0;
}