Pagini recente » Cod sursa (job #1899021) | Cod sursa (job #1169387) | Cod sursa (job #3168373) | Cod sursa (job #939841) | Cod sursa (job #2876426)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
priority_queue < int > heap;
int n, v[200000];
bool deSters[200000];
int main()
{
ifstream f("heapuri.in");
ofstream g("heapuri.out");
f >> n;
int 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.empty() )
heap.pop();
}
}
else
g << -heap.top() << endl;
}
f.close();
g.close();
return 0;
}