[C++] 백준 11279


[C++] 백준 11279

문제 소스 코드 #include <iostream> #include <vector> #define HEAP_SIZE 100001 #define HEAP_EMPTY(n) (!n) #define HEAP_FULL(n) (n == HEAP_SIZE - 1) using namespace std; int max_heap[100001] = {0}; int cursor = 0; void push(int key) { if(HEAP_FULL(cursor)) return; int i = ++cursor; while(i != 1 && max_heap[i/2] < key) { max_heap[i] = max_heap[i/2]; i /= 2; } max_heap[i] = key; } void pop() { if(HEAP_EMPTY(cursor)) return; int parent = 1; int child = 2; max_heap[1] = max_heap[cursor]; max_heap[cursor--] ...



원문링크 : [C++] 백준 11279