1. 문제 설명
https://www.acmicpc.net/problem/11279
https://jaeseo0519.tistory.com/40#%EC%B-%-C%EC%--%-C%ED%-E%--
그냥 힙을 공부해보고 싶어서 직접 구현해서 풀었던 문제..얜 귀찮아서 안했는데
최소힙을 그냥 뒤집어주면 된다.
2. 아이디어
-
3. 코드
import heapq
import sys
input = sys.stdin.readline
def solution():
n = int(input())
heap = []
for _ in range(n):
x = int(input())
if x == 0:
try:
print(heapq.heappop(heap)[1])
except:
print(0)
else:
heapq.heappush(heap, (-x, x))
solution()