과제
1. 개요
2. 그리디
import sys
N = int(sys.stdin.readline())
HOMEWORKS = []
visit = [False] * 1001
for _ in range(N):
d, w = map(int, sys.stdin.readline().split())
HOMEWORKS.append((d, w))
HOMEWORKS.sort(key=lambda x: x[1], reverse=True)
answer = 0
for day, worth in HOMEWORKS:
i = day
while i>0 and visit[i]:
i-=1
if i==0:
continue
else:
visit[i] = True
answer += worth
print(answer)
Leave a comment