Pagini recente » Cod sursa (job #274775) | Cod sursa (job #1065294) | Cod sursa (job #2257071) | Cod sursa (job #1714094) | Cod sursa (job #2169286)
#include <iostream>
#include <fstream>
#include <queue>
#include <cstdlib>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
const int NLIM = 2e5+10;
int n;
bool b[NLIM];
struct cucc
{
int val, tim;
};
class compar
{
public:
bool operator() (cucc a, cucc b)
{
return a.val > b.val;
}
};
priority_queue < cucc, vector < cucc >, compar > heap;
int main()
{
fin >> n;
int i = 1;
while(n--)
{
int t;
fin >> t;
if(t == 1)
{
cucc x;
x.tim = i;
++i;
fin >> x.val;
heap.push(x);
}
else if(t == 2)
{
int x;
fin >> x;
b[x] = true;
}
else
{
while(b[heap.top().tim])
{
heap.pop();
}
fout << heap.top().val << "\n";
}
}
return 0;
}