Pagini recente » Cod sursa (job #2340611) | Cod sursa (job #625504) | Cod sursa (job #317404) | Cod sursa (job #1734291) | Cod sursa (job #1977887)
#include <iostream>
#include <fstream>
#include <queue>
#include <vector>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
priority_queue <int, vector<int>, greater<int>> p, q;
vector <int> history;
int n, cod, x;
int main()
{
fin >> n;
while (n--)
{
fin >> cod;
switch (cod)
{
case 1:
{
fin >> x;
p.push(x);
history.push_back(x);
break;
}
case 2:
{
fin >> x;
q.push(history[x - 1]);
break;
}
case 3:
{
while (!p.empty() && !q.empty() && p.top() == q.top())
{
p.pop();
q.pop();
}
fout << p.top() << '\n';
break;
}
}
}
return 0;
}