백준 1927

    [BaekJoon] 백준 1927번 최소 힙

    [BaekJoon] 백준 1927번 최소 힙 문제: https://www.acmicpc.net/problem/1927 내코드 우선 순위큐에서 힙을 이용해 푸는 문제다. 파이썬에는 힙 모듈이 있어 이를 이용해서 풀었다. # BaekJoon1927.py import sys import heapq input = sys.stdin.readline number = int(input()) heap = [] for _ in range(number): num = int(input()) if num != 0: heapq.heappush(heap, num) else: try: print(heapq.heappop(heap)) except: print(0)