Skip to content

Commit

Permalink
절대값힙
Browse files Browse the repository at this point in the history
  • Loading branch information
hwkkkk committed Jun 25, 2024
1 parent 3b41717 commit fe488ae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 강현욱/11286.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
import heapq
input = sys.stdin.readline

ls=[]
count = int(input())
for j in range(count):
num=int(input())
if num>0:
heapq.heappush(ls, (num,num))
elif num==0:
if len(ls)==0:
print(0)
else:
print(heapq.heappop(ls)[1])
else:
heapq.heappush(ls, (-num,num))

0 comments on commit fe488ae

Please sign in to comment.