From c29003e0851e2448d9976343d993a05f1b8e1aa5 Mon Sep 17 00:00:00 2001 From: wwan13 Date: Wed, 1 May 2024 17:19:56 +0900 Subject: [PATCH] =?UTF-8?q?solve=20:=201927=20=EC=B5=9C=EC=86=8C=20?= =?UTF-8?q?=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/boj_1927.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 python/boj_1927.py diff --git a/python/boj_1927.py b/python/boj_1927.py new file mode 100644 index 0000000..186f0ca --- /dev/null +++ b/python/boj_1927.py @@ -0,0 +1,27 @@ +import sys +import heapq + +input = sys.stdin.readline + + +def solution(n): + heap = list() + + for i in range(n): + num = int(input()) + if num == 0: + if len(heap) == 0: + print(0) + else: + print(heapq.heappop(heap)) + continue + + heapq.heappush(heap, num) + + +def main(): + n = int(input()) + solution(n) + + +main()