백준 파이썬 14728번 벼락치기
Gold 5
https://www.acmicpc.net/problem/14728
n, t = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)] #공부시간, 배점
dp = [0]*(t+1)
for time, score in lst:
for i in range(t, time-1, -1):
dp[i] = max(dp[i], dp[i-time]+score)
print(dp[t])
냅색 유형의 문제로 dp를 사용해서 얻을 수 있는 최대점수를 구해주면 된다.
다음 문제와 거의 똑같다!
https://www.acmicpc.net/problem/12865
반응형
'IT > 알고리즘' 카테고리의 다른 글
[백준 Python] 1958번 LCS 3 (0) | 2025.02.17 |
---|---|
[백준 Python] 14503번 로봇 청소기 (0) | 2025.02.13 |
[백준 Python] 19942번 다이어트 (2) | 2025.02.06 |
[백준 Python] 12919번 A와 B 2 (0) | 2025.02.06 |
[백준 Python] 2573번 빙산 (0) | 2025.01.25 |