irapilguy

Untitled

Nov 3rd, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4. #define N 1000000
  5. int heap[N];
  6. void siftUp(int a) {
  7. int p = a / 2;
  8. if (heap[a] > heap[p]) {
  9. swap(a, p);
  10. siftUp(a);
  11. }
  12. }
  13. void swap(int i, int j) {
  14. int x = heap[i];
  15. heap[i] = heap[j];
  16. heap[j] = x;
  17. }
  18. int main() {
  19. int n;
  20. cin >> n;
  21. for (int i = 1; i <= n; i++) {
  22. cin >> heap[i];
  23. }
  24. }
Add Comment
Please, Sign In to add comment