This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import heapq | |
n = int(input()) | |
arr = [] | |
for i in range(n): | |
command = int(sys.stdin.readline().rstrip()) | |
if command != 0: | |
heapq.heappush(arr, command) | |
else: | |
if arr: | |
print(heapq.heappop(arr)) | |
else: | |
print(0) |
'python' 카테고리의 다른 글
이런식으로도 문자열 만들 수 있다 (0) | 2021.03.03 |
---|---|
파이썬으로 현재 시간 출력하기 - datetime (0) | 2021.02.27 |
list.pop(index) (0) | 2021.02.23 |
* 출력 (0) | 2021.02.22 |
set() (0) | 2021.02.09 |