Pagini recente » Cod sursa (job #2954048) | Cod sursa (job #636302) | Cod sursa (job #2610185) | Cod sursa (job #1270060) | Cod sursa (job #3130430)
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
class HeapOperations {
private:
multiset<int> heap;
vector<int> v;
int k = 0;
void executeOption(int option) {
int x;
switch (option) {
case 1: {
fin >> x;
heap.insert(x);
v.push_back(x);
break;
}
case 2: {
fin >> x;
heap.erase(v.at(x - 1));
break;
}
case 3: {
fout << *heap.begin() << "\n";
break;
}
}
}
public:
void start() {
int n, option;
fin >> n;
for (int i = 0; i < n; i++) {
fin >> option;
executeOption(option);
}
fin.close();
fout.close();
}
};
int main() {
HeapOperations heapOps;
heapOps.start();
return 0;
}