8000 [23-02-23] dain.py by da-in · Pull Request #131 · da-in/algorithm-study · GitHub
[go: up one dir, main page]

Skip to content

[23-02-23] dain.py #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
📝 Create [힙] 이중우선순위큐 dain.py
  • Loading branch information
da-in committed Feb 22, 2023
commit e2ada72732f22c80bfb30e7f3ece07facd4dd0c1
15 changes: 15 additions & 0 deletions Programmers - 고득점 Kit/[힙] 이중우선순위큐/dain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from heapq import heappush, heappop

def solution(operations):
answer = []
hq = []
for o in operations:
if o[0] == "I":
heappush(hq, int(o[2:]))
elif hq:
if o[2:] == "-1":
heappop(hq)
else:
hq.pop(-1)

return [0, 0] if len(hq) == 0 else [max(hq), min(hq)]
0