250x250
Notice
Recent Posts
Recent Comments
Link
반응형
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 스프링부트
- BFS
- NIO
- 큐
- map
- GC로그수집
- union_find
- date
- List
- alter
- spring boot
- dfs
- set
- scanner
- 힙덤프
- Properties
- CSS
- 리소스모니터링
- sql
- math
- priority_queue
- Calendar
- javascript
- string
- deque
- Union-find
- JPA
- Java
- 스택
- html
Archives
- Today
- Total
매일 조금씩
백준 11279번: 최대 힙 본문
728x90
반응형


priority_queue를 활용한 간단한 문제다.
#include <iostream>
#include <queue>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0); //cin 실행속도 향상
int n;
cin >> n;
priority_queue<int> pq;
for (int i = 0; i < n; i++) {
int op;
cin >> op;
if (op > 0) {
pq.push(op);
}
else if (!op) {
if (!pq.empty()) {
cout << pq.top() << "\n";
pq.pop();
}
else
cout << "0\n";
}
}
return 0;
}728x90
반응형
'알고리즘' 카테고리의 다른 글
| 백준 11286번: 절댓값 힙 (0) | 2020.04.10 |
|---|---|
| 백준 1927번: 최소 힙 (0) | 2020.04.09 |
| 백준 5430번: AC (0) | 2020.04.09 |
| 백준 1021번: 회전하는 큐 (0) | 2020.04.08 |
| 백준 10866번: 덱 (0) | 2020.04.08 |