Pagini recente » Cod sursa (job #2015799) | Monitorul de evaluare | Istoria paginii runda/boolanelvsbobulous/clasament | Cod sursa (job #654848) | Cod sursa (job #1910033)
#include <bits/stdc++.h>
using namespace std;
const int nMax = 2e5 + 2;
bool erased[nMax];
vector<int>v;
priority_queue<pair<int, int>>pq;
void upd_pq() {
while (!pq.empty() and erased[pq.top().second])
pq.pop();
}
int main() {
ifstream cin("heapuri.in");
ofstream cout("heapuri.out");
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int tip, x;
cin >> tip;
if (tip == 3) {
upd_pq();
cout << -pq.top().first << '\n';
}
else {
cin >> x;
v.push_back(x);
if (tip == 1)
pq.emplace(-x, v.size());
else erased[x] = true;
}
}
return 0;
}