Pagini recente » Cod sursa (job #3038277) | Cod sursa (job #69303) | Cod sursa (job #306493) | Cod sursa (job #570508) | Cod sursa (job #2285432)
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <queue>
#include <set>
#define MAX_INT 0x3f3f3f3f;
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
const int MAX_HEAP_SIZE = 16324;
int Heap[MAX_HEAP_SIZE];
int father(int nod) {
return nod / 2;
}
int left_son(int nod) {
return 2 * nod + 1;
}
int right_son(int nod) {
return 2 * nod + 2;
}
int heapMax(int H[]) {
return H[0];
}
void siftare(int H[], int N, int K) {
int son;
do {
son = 0;
if (left_son(K) <= N) {
son = left_son(K);
if (right_son(K) <= N && H[right_son(K)] > H[left_son(K)]) {
son = right_son(K);
}
if (H[son] <= H[K]) {
son = 0;
}
}
if (son) {
swap(H[K], H[son]);
K = son;
}
} while (son);
}
void percolate(int H[], int N, int K) {
int key = H[K];
while ((K > 1) && (key > H[father(K)])) {
H[K] = H[father(K)];
K = father(K);
}
H[K] = key;
}
int main() {
multiset<int> my_set1;
vector<int> hist;
int n, a, b;
fin >> n;
for (int i = 0; i < n; i++) {
fin >> a;
if (a == 1) {
fin >> b;
my_set1.insert(b);
hist.push_back(b);
}
if (a == 2) {
fin >> b;
multiset <int>::iterator it = my_set1.find(hist[b- 1]);
if (it != my_set1.end()) {
my_set1.erase(it);
}
}
if (a == 3) {
multiset<int>::iterator it = my_set1.begin();
fout << *it << '\n';
}
}
return 0;
}