Pagini recente » Cod sursa (job #57952) | Cod sursa (job #2200097) | Cod sursa (job #1848004) | Cod sursa (job #1769118) | Cod sursa (job #1922308)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
int main() {
int k;
vector<int> v, z;
in >> k;
for(int i = 0; i < k; i++) {
make_heap(v.begin(), v.end());
sort_heap(v.begin(), v.end());
int x;
in >> x;
if(x == 1) {
int y;
in >> y;
v.push_back(y);
z.push_back(y);
}
else if(x == 2) {
int a;
in >> a;
a--;
v.erase(find(v.begin(), v.end(), z[a]));
z.erase(find(z.begin(), z.end(), z[a]));
}
else {
out << v.front() << '\n';
}
}
return 0;
}