#include<stdio.h>
#include<stdlib.h>
void insert(int i, int a[], int n);
int deletemin(int a[], int n, int m);
int main(void) {
int a[10] = {91, 63, 71, 14, 60, 1, 24, 13, 80, 15};
int m[10];
int i, j;
int n = 10;
for (i = (n - 2) / 2; i >= 0; i--) {
insert(i, a, n - 1);
}
for (i = n - 1; i >= 0; i--) {
m[9 - i] = deletemin(a, i, i - 1);
}
for (j = 0; j < 10; j++) {
}
return 0;
}
void insert(int i, int a[], int n) {
int j;
int temp;
while (2 * i + 1 <= n) {
j = 2 * i + 1;
if (j < n) {
if (a[j] > a[j + 1]) {
j++;
}
}
if (a[i] <= a[j]) {
break;
}
temp = a[j];
a[j] = a[i];
a[i] = temp;
i = j;
}
}
int deletemin(int a[], int n, int m) {
int b;
int temp;
int i, j;
b = a[0];
a[0] = a[n];
i = 0;
while (2 * i + 1 <= m) {
j = 2 * i + 1;
if (j < m) {
if (a[j] > a[j + 1]) {
j++;
}
}
if (a[i] <= a[j]) {
break;
}
temp = a[i];
a[i] = a[j];
a[j] = temp;
i = j;
}
return b;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+Cgp2b2lkIGluc2VydChpbnQgaSwgaW50IGFbXSwgaW50IG4pOwppbnQgZGVsZXRlbWluKGludCBhW10sIGludCBuLCBpbnQgbSk7CgppbnQgbWFpbih2b2lkKSB7CglpbnQgYVsxMF0gPSB7OTEsIDYzLCA3MSwgMTQsIDYwLCAxLCAyNCwgMTMsIDgwLCAxNX07CglpbnQgbVsxMF07CglpbnQgaSwgajsKCWludCBuID0gMTA7CgoJZm9yIChpID0gKG4gLSAyKSAvIDI7IGkgPj0gMDsgaS0tKSB7CgkJaW5zZXJ0KGksIGEsIG4gLSAxKTsKCX0KCglmb3IgKGkgPSBuIC0gMTsgaSA+PSAwOyBpLS0pIHsKCQltWzkgLSBpXSA9IGRlbGV0ZW1pbihhLCBpLCBpIC0gMSk7Cgl9CgoJZm9yIChqID0gMDsgaiA8IDEwOy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