---
layout: post
title:  " 최대 힙"
date:   2018-02-15
excerpt: "BOJ_11279"
cate : "algorithm"
tag:
- BOJ
- Priority Queue
---

## Problem 
Problem URL : **[최대 힙](https://www.acmicpc.net/problem/11279)**

{% capture images %}
    /assets/img/algorithm/11279_1.png
    /assets/img/algorithm/11279_2.png
{% endcapture %}
{% include gallery images=images caption="Screenshots of Problem Explain" cols=2 %}

---
 
## Answer Code (1) [18. 02. 15]
{% highlight cpp %}

#include<iostream>
#include<queue>
using namespace std;

// Root is Max Value
priority_queue<int> pq;
//priority_queue<int,vector<int>,less<int> > pq;

int main(void) {
    int tc;
    cin >> tc;
    
    while (tc--) {
        int a;
        scanf("%d",&a);
        
        if( a==0 ){
            if( pq.empty() ){
                printf("0\n");
            }
            else{
                printf("%d\n",pq.top());
                pq.pop();
            }
        }
        else{
            pq.push(a);
        }
    }
    
    return 0;
}

{% endhighlight %}


---
## Code Review

### Answer Code (1) [18. 02. 15]

* Code가 중요한게 아니다. [`Priority Queue`](https://goodgid.github.io/Priority-Queue/) 개념을 익히는게 중요하다.

Write a BOJ Post ' 최대 힙 ' and Add ScreenShot's
Write a BOJ Post ' 최대 힙 ' and Add ScreenShot's
