题目描述
参考题解
if __name__ == "__main__": N, V = map(int, input().split()) dp = [0] * (V + 1) v = [] w = [] for _ in range(N): a, b, c = map(int, input().split()) k = 1 while c > k: v.append(a*k) w.append(b*k) c -= k k *= 2 if c: v.append(a*c) w.append(b*c) for i in range(len(v)): for j in range(V, v[i]-1, -1): dp[j] = max(dp[j], dp[j - v[i]] + w[i]) print(dp[V])