Skip to content

Commit

Permalink
solve : 1927 최소 힙
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 1, 2024
1 parent 5a9d708 commit c29003e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/boj_1927.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit c29003e

Please sign in to comment.