λ¬Έμ
https://www.acmicpc.net/problem/1535
νμ΄
# λ°±μ€ 1535λ² λ¬Έμ - μλ
import sys
input = sys.stdin.readline
n = int(input())
stamina_consum = [0] + list(map(int, input().split()))
get_pleasure = [0] + list(map(int, input().split()))
dp = [[0] * 101 for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, 101):
if stamina_consum[i] <= j:
dp[i][j] = max(dp[i-1][j], dp[i-1][j - stamina_consum[i]] + get_pleasure[i])
else:
dp[i][j] = dp[i-1][j]
print(dp[n][99])
DP / μμ νμ / λ°°λ λ¬Έμ μ΄λ€.
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] [Gold4] 11054λ²_κ°μ₯ κΈ΄ λ°μ΄ν λ λΆλΆ μμ΄ (1) | 2023.05.09 |
---|---|
π© [λ°±μ€] [Python] [Gold4] 14500λ²_ν νΈλ‘λ―Έλ Έ (1) | 2023.05.08 |
π© [λ°±μ€] [Python] [Gold3] 2252λ²_μ€ μΈμ°κΈ° (1) | 2023.05.04 |
π© [λ°±μ€] [Python] [Gold5] 2096λ²_λ΄λ €κ°κΈ° (2) | 2023.05.03 |
π© [λ°±μ€] [Python] [Silver1] 11057λ²_μ€λ₯΄λ§ μ (2) | 2023.05.02 |