Pagini recente » Cod sursa (job #525150) | Cod sursa (job #2797735) | Cod sursa (job #1147269) | Cod sursa (job #886088) | Cod sursa (job #2734834)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream gout("heapuri.out");
priority_queue <pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> heap;
int n, op, x, index_push;
bool stare[200002];
int main()
{
fin >> n;
for (int t = 1 ; t <= n; ++t)
{
fin >> op;
switch(op)
{
case 1:
{
fin >> x;
++index_push;
heap.push({x, index_push});
stare[index_push] = 1;
break;
}
case 2:
{
fin >> x;
stare[x] = 0;
break;
}
case 3:
{
while(stare[heap.top().second] == 0)
heap.pop();
gout << heap.top().first << '\n';
break;
}
}
}
return 0;
}