Pagini recente » Cod sursa (job #2446904) | Cod sursa (job #3261665) | Cod sursa (job #1598345) | Cod sursa (job #3247561) | Cod sursa (job #3131250)
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
set<int> multipliiE;
vector<int> elemente;
int auxiliar = 0;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
void inserareElement(int nr) {
elemente.push_back(nr);
multipliiE.insert(nr);
}
void stergereElement(int pozitie) {
int x = elemente[pozitie];
multipliiE.erase(x);
}
int main() {
int nrOperatii;
in >> nrOperatii;
vector<pair<int, int>> operatii;
for (int i = 0; i < nrOperatii; ++i) {
int tipOperatie, nr;
in >> tipOperatie;
if (tipOperatie == 1 || tipOperatie == 2) {
in >> nr;
operatii.push_back({tipOperatie, nr});
} else {
operatii.push_back({tipOperatie, -1});
}
}
for (const auto& op : operatii) {
int tipOperatie = op.first;
int nr = op.second;
if (tipOperatie == 1) {
inserareElement(nr);
} else if (tipOperatie == 2) {
stergereElement(nr - 1);
} else if (tipOperatie == 3) {
out << *multipliiE.begin() << endl;
}
}
in.close();
out.close();
return 0;
}