Pagini recente » Borderou de evaluare (job #2018950) | Cod sursa (job #2604012) | Cod sursa (job #3279275) | Borderou de evaluare (job #444313) | Cod sursa (job #1646878)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");
struct heap {
int x, pos;
bool operator< (const heap &a) const
{
return x > a.x;
}
};
priority_queue <heap> myHeap;
bool used[250000];
int N, M;
int main()
{
fin >>N;
for (int i = 1; i <= N; ++i)
{
int type,x;
heap temp;
fin >>type;
if (type == 1)
{
fin >>x;
temp.x = x;
temp.pos = ++M;
myHeap.push(temp);
}
if (type == 2)
{
fin >>x;
used[x] = 1;
}
if (type == 3)
{
while (!myHeap.empty() && used[myHeap.top().pos])
myHeap.pop();
fout <<myHeap.top().x <<'\n';
}
}
return 0;
}