Pagini recente » Cod sursa (job #173273) | Cod sursa (job #2228130) | Cod sursa (job #3166367) | Cod sursa (job #732492) | Cod sursa (job #3163587)
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> poz;
priority_queue <int, vector <int>, greater <int>> allValues, deleteValues;
int main()
{
ios_base :: sync_with_stdio(0);
cin.tie(0);
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
cin >> n;
poz.push_back(0);
for(int i = 1; i <= n; i ++)
{
int x;
cin >> x;
if(x == 1)
{
int val;
cin >> val;
allValues.push(val);
poz.push_back(val);
}
else if(x == 2)
{
int val;
cin >> val;
deleteValues.push(poz[val]);
// cout << poz[val] << "a ";
}
else
{
while(!deleteValues.empty() && deleteValues.top() == allValues.top())
{
deleteValues.pop();
allValues.pop();
}
cout << allValues.top() << "\n";
}
}
return 0;
}