Pagini recente » Cod sursa (job #2016058) | Cod sursa (job #622186) | Cod sursa (job #2760118) | Cod sursa (job #1584496) | Cod sursa (job #2734526)
#include <iostream>
#include <queue>
#include <fstream>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int main() {
int n;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
vector<pair<int,int>> elemente;
fin >> n;
int idx = 0;
for (int i = 0; i < n; i++) {
int optiune;
int numar;
fin >> optiune;
if (optiune == 3) {
while (elemente[pq.top().second].second == 0) {
pq.pop();
}
fout << pq.top().first << '\n';
}
else if (optiune == 1) {
fin >> numar;
pq.push({ numar,idx++ });
elemente.push_back({ numar,1 });
}
else if (optiune == 2) {
fin >> numar;
elemente[numar - 1].second = 0;
}
}
}