python 解
n,m = map(int,input().split())
v,w,s = [0 for i in range(n+1)],[0 for i in range(n+1)],[0 for i in range(n+1)]
for i in range(1,n+1):
v[i],w[i],s[i] = map(int,input().strip().split())
#二维解
print(v,w,s)
dp = [[0] *(m+1) for _ in range(n+1)]
for i in range(1,n+1):
for j in range(1,m+1):
for k in range(s[i]+1):
if j >= k*v[i]:
dp[i][j] = max(max(dp[i-1][j],dp[i-1][j-k*v[i]]+k*w[i]),dp[i][j])
print(dp[-1][-1])
#一维解
dp = [0 for i in range(m+1)]
for i in range(1,n+1):
for j in range(m,-1,-1):
for k in range(s[i]+1):
if j >= k*v[i]:
dp[j] = max(dp[j],dp[j-k*v[i]]+k*w[i])
print(dp[-1])