/ Java题解 /
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while((line = br.readLine())!= null) {
int N = Integer.parseInt(line.split(” “)[0]);
int V = Integer.parseInt(line.split(” “)[1]);
int[] cost = new int[N];
int[] value = new int[N];
int[] count = new int[N];
for(int i = 0; i < N; i) {
line = br.readLine();
String[] temp = line.split(” “);
cost[i] = Integer.parseInt(temp[0]);
value[i] = Integer.parseInt(temp[1]);
count[i] = Integer.parseInt(temp[2]);
}
int[] dp = new int[V + 1];
for(int i = 0; i < N; i) {
for(int j = V; j >= cost[i]; j–) {
for(int k = 0; k * cost[i] <= j && k <= count[i]; k++) {
dp[j] = Math.max(dp[j], dp[j - k * cost[i]] + k * value[i]);
}
}
}
System.out.println(dp[V]);
}
}
}