algorithm'''problem solve

[백준] 11279 - 최대 힙(설명X)

JunHwa Park 2020. 4. 17. 22:33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
 
int main() {
    priority_queue<int> p_queue;
    int N;
    scanf("%d"&N);
 
    for (int i = 0; i < N; i++) {
        int num;
        scanf("%d"&num);
 
        switch (num)
        {
        case 0:
            if (p_queue.size() == 0)
                printf("0\n");
            else {
                printf("%d\n", p_queue.top());
                p_queue.pop();
            }
            break;
        default:
            p_queue.push(num);
            break;
        }
    }
    return 0;
}
cs