堆排序
void push_down(vector <int>& s, int size, int u) {
int t = u, l = u * 2, r = u * 2 + 1;
if (l <= size && s[l] > s[t])t = l;
if (r <= size && s[r] > s[t])t = r;
if (t != u) {
swap(s[t], s[u]);
push_down(s, size, t);
}
}
void push_up(vector <int>& s, int u) {
while (u / 2 && s[u / 2] < s[u]) {
swap(s[u / 2], s[u]);
u /= 2;
}
}
void heapsort(vector <int>& s, int n) {
int size = n;
for (int i = 1; i <= n; i++) push_up(s, i);
for (int i = 1; i <= n; i++) {
swap(s[1], s[size]);
size--;
push_down(s, size, 1);
}
}