Skip to content

Commit b4e1daa

Browse files
committed
[BOJ] #11286. 절댓값 힙 / 실버1 / 30분 / 힌트, 성공
1 parent 36a076b commit b4e1daa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
import heapq
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
abs_heap = []
7+
8+
for _ in range(n):
9+
num = int(input())
10+
if num == 0:
11+
if abs_heap:
12+
print(heapq.heappop(abs_heap)[1])
13+
else:
14+
print(0)
15+
else:
16+
heapq.heappush(abs_heap, (abs(num), num))

0 commit comments

Comments
 (0)