def solution(goods, max_weight):
dp = [0] * (max_weight + 1)
for weight, value in goods:
for w in range(max_weight, weight - 1, -1):
dp[w] = max(dp[w], dp[w - weight] + value)
return dp[max_weight]
goods = [[10, 60], [20, 100], [30, 120]]
max_weight = 50
print(solution(goods, max_weight))
To embed this project on your website, copy the following code and paste it into your website's HTML: