https://www.acmicpc.net/problem/2109
2109번: 순회강연
한 저명한 학자에게 n(0 ≤ n ≤ 10,000)개의 대학에서 강연 요청을 해 왔다. 각 대학에서는 d(1 ≤ d ≤ 10,000)일 안에 와서 강연을 해 주면 p(1 ≤ p ≤ 10,000)만큼의 강연료를 지불하겠다고 알려왔다.
www.acmicpc.net
날짜보다 강의한 숫자가 더 크면 가장 싼 강연 포기
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
n=int(input())
arr=[list(map(int, input().split())) for _ in range(n)]
arr.sort(key=lambda x: x[1])
heap=[]
for i in arr:
heappush(heap, i[0])
if (len(heap)>i[1]):
heappop(heap)
print(sum(heap))
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 17069 17070 파이프 옮기기1, 2 (0) | 2021.09.15 |
---|---|
[백준][Python] 20040 사이클게임 (0) | 2021.09.15 |
[백준][Python] 18427 함께 블록 쌓기 (0) | 2021.09.14 |
[백준][Python] 17406 배열돌리기 4 (0) | 2021.09.14 |
[백준][Python] 12871 무한문자열 (0) | 2021.09.14 |