처음에 정렬을 날짜말고 가격만 고려해서 정렬하면 된다.
그리고 해당 강연을 최대한 뒤의 날로 정하면 된다.
https://www.acmicpc.net/problem/2109
import sys
ans = [0] * 10001
n = int(sys.stdin.readline())
data = []
for i in range(n):
p, d = map(int, sys.stdin.readline().split())
data.append((p, d))
data.sort(key= lambda x:-x[0])
for p, d in data:
while ans[d] != 0:
d -= 1
if d != 0:
ans[d] = p
print(sum(ans))
'알고리즘 문제풀이' 카테고리의 다른 글
치킨 TOP N [백준 11582] (0) | 2024.07.21 |
---|---|
줄 세우기 [백준 11536] (0) | 2024.07.19 |
공주님의 정원[백준 2457] (0) | 2024.07.18 |
팀 이름 정하기[백준 1296] (0) | 2024.07.17 |
쇠막대기[백준 10799] (0) | 2024.07.16 |