Pagini recente » Cod sursa (job #365762) | Cod sursa (job #1376991) | Cod sursa (job #1765649) | Cod sursa (job #1744392) | Cod sursa (job #1329283)
#include <fstream>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");
int n, op, x;
struct data {
int val;
int poz;
}
int main () {
fin >> n;
while (n--) {
fin >> op;
if (op == 1) {
fin >> x;
h[++k] = k;
v[k].val = x;
v[k].poz = k;
c = k;
p = k/2;
while (c != 1 && v[h[p]].val > v[h[c]].val) {
int aux = h[c];
h[c] = h[p];
h[p] = aux;
v[h[p]].poz = p;
v[h[c]].poz = c;
p /= 2;
c /= 2;
}
continue;
}
if (op == 2) {
fin >> x;
v[x].val = -1;
c =
}
return 0;
}