Pagini recente » Cod sursa (job #71806) | Cod sursa (job #1163041)
#include <fstream>
#include <queue>
#include <bitset>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
typedef pair< int, int > cheie;
int M, x, tip, nr;
priority_queue < cheie, vector < cheie >, greater< cheie > > H;
bitset < 200005 > scos;
int main()
{
f>>M;
for (int i=1; i<=M; ++i)
{
f>>tip;
if (tip==1) f>>x, H.push(cheie(x, ++nr));
else if (tip==2) f>>x, scos[x]=1;
else
{
while (scos[H.top().second]) H.pop();
g<<H.top().first<<'\n';
}
}
return 0;
}