Notice
Recent Posts
Recent Comments
Link
나의 개발일지
[백준] 1927 최소 힙 [Python, 파이썬] 본문
- 문제 : https://www.acmicpc.net/problem/1927
- 🔑 최소 힙
from heapq import heappop, heappush
import sys
input = sys.stdin.readline
n = int(input())
heap = []
for _ in range(n):
x = int(input())
if not heap and x == 0:
print(0)
elif x > 0:
heappush(heap, x)
else:
print(heappop(heap))
'백준' 카테고리의 다른 글
[백준] 1747 소수 & 팰린드롬 [Python, 파이썬] (0) | 2024.01.03 |
---|---|
[백준] 1715 카드 정렬하기 [Python, 파이썬] (0) | 2024.01.03 |
[백준] 19496 큰 수 만들기 [Python, 파이썬] (0) | 2023.12.24 |
[Python] schedule 모듈 (0) | 2023.12.18 |
[백준] 21939 문제 추천 시스템 Version1 [Python, 파이썬] (0) | 2023.12.14 |
Comments