max_weight = 7
items = [[6, 13], [4, 8], [3, 6], [5, 12]]
dp = [0] * (max_weight + 1)
for weight, value in items:
for w in range(max_weight, weight - 1, -1):
dp[w] = max(dp[w], dp[w - weight] + value)
print(dp[max_weight])
To embed this project on your website, copy the following code and paste it into your website's HTML: