Pagini recente » Cod sursa (job #2725673) | Cod sursa (job #1090388) | Cod sursa (job #433165) | Cod sursa (job #1777716) | Cod sursa (job #1986901)
#include <iostream>
#include <queue>
#include <fstream>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
const int NLIM = 2e5 + 10;
int N;
int bv[NLIM];
struct xS
{
int val, time;
};
class comparC
{
public:
bool operator() ( xS x1, xS x2 )
{
return x1.val > x2.val;
}
};
int main()
{
priority_queue< xS, vector< xS >, comparC > hip;
fin >> N;
int i = 1;
while( N-- )
{
int t;
fin >> t;
if( t == 1 )
{
xS x;
x.time = i; ++i;
fin >> x.val;
hip.push( x );
}
else if( t == 2 )
{
int x;
fin >> x;
bv[x] = 1;
}
else
{
while( bv[hip.top().time] )
{
//cout << " " << hip.top().val << "\n";
hip.pop();
}
// cout << hip.top().time << " ";
fout << hip.top().val << "\n";
}
}
return 0;
}