Skip to content

Commit

Permalink
solve : 2109 순회강연
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 17, 2024
1 parent 8d303c4 commit a816bce
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions python/boj_2109.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
import heapq

input = sys.stdin.readline


def solution(n, data):
data.sort(key=lambda x: x[1])

queue = list()
for e in data:
reward, date = e
heapq.heappush(queue, reward)

if len(queue) > date:
heapq.heappop(queue)

return sum(queue)


def display_result(answer):
print(answer)


def main():
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
answer = solution(n, data)
display_result(answer)


main()

0 comments on commit a816bce

Please sign in to comment.