Pagini recente » Rating Tammara Hornibrook (mireya2444) | Cod sursa (job #202837) | Cod sursa (job #2023760) | Rating titi dan (titel1) | Cod sursa (job #1460766)
#include <bits/stdc++.h>
using namespace std;
typedef int var;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
#define MAXN 200005
bool inH[MAXN];
var Val[MAXN];
int t;
auto cmp = [](var a, var b) {
return Val[a] > Val[b];
};
priority_queue<var, vector<var>, decltype(cmp)> Heap(cmp);
void ins(int val) {
t++;
Val[t] = val;
inH[t] = 1;
Heap.push(t);
}
void del(int val) {
inH[val] = 0;
}
var getMin() {
while(!inH[Heap.top()])
Heap.pop();
return Val[Heap.top()];
}
int main() {
int n, type;
var x;
fin>>n;
while(n--) {
fin>>type;
if(type == 3) { fout<<getMin()<<'\n'; continue; }
fin>>x;
if(type == 1) ins(x);
else del(x);
}
}