Pagini recente » Cod sursa (job #3291005) | Cod sursa (job #3040255) | Cod sursa (job #2446468) | Cod sursa (job #3148032) | Cod sursa (job #1807937)
#include <fstream>
#include <queue>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
const int Max = 200010;
struct heap
{
int x, ind;
bool operator <(const heap &aux) const
{
return x > aux.x;
}
};
priority_queue<heap> h;
char vaz[Max];
int main()
{
int n, tur, x, cnt = 0;
in >> n;
for(int i = 1; i <= n ;++i)
{
in >> tur;
switch(tur)
{
case 1:
in >> x;
h.push({x,++cnt});
break;
case 2:
in >> x;
vaz[x] = 1;
break;
case 3:
while(!h.empty() && vaz[h.top().ind])
h.pop();
out << h.top().x << "\n";
break;
}
}
}