Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- #define N 1000000
- int heap[N];
- void siftUp(int a) {
- int p = a / 2;
- if (heap[a] > heap[p]) {
- swap(a, p);
- siftUp(a);
- }
- }
- void swap(int i, int j) {
- int x = heap[i];
- heap[i] = heap[j];
- heap[j] = x;
- }
- int main() {
- int n;
- cin >> n;
- for (int i = 1; i <= n; i++) {
- cin >> heap[i];
- }
- }
Add Comment
Please, Sign In to add comment