Pagini recente » Cod sursa (job #804610) | Cod sursa (job #1324330) | Cod sursa (job #2889273) | Cod sursa (job #781986) | Cod sursa (job #2270555)
#include <fstream>
#include <climits>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> heap;
int N, x, n, cer, used[200003];
int main()
{
f >> N;
for(int i = 1; i <= N; i++) {
f >> cer;
if(cer == 1) {
f >> x;
heap.push({x, i});
} else if(cer == 2) {
f >> x;
used[x] = true;
} else {
while(!heap.empty() && used[heap.top().second])
heap.pop();
g << heap.top().first << "\n";
}
}
return 0;
}