解题思路:
注意事项:
参考代码:
V = int(input())
n = int(input())
dp = [0]*(V+1)
c = [0]*(n+1)
for i in range(1, n+1):
c[i]=int(input())
for i in range(1,n+1):
for j in range (V,c[i]-1,-1):
dp[j] = max(dp[j], dp[j-c[i]]+c[i])
print(V-dp[V])
0.0分
0 人评分