🍑 庆功会
输入
5 1000
80 20 4
40 50 9
30 50 7
40 30 6
20 20 1
输出
1040
import java.util.Scanner;
public class Main
{
static int N = 6010;
static int[] f = new int[N];
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
for (int i = 0; i < n; i++)
{
int v = sc.nextInt();
int w = sc.nextInt();
int s = sc.nextInt();
for (int j = m; j >= v; j--)
for (int k = 0; k <= s && k * v <= j; k++)
f[j] = Math.max(f[j], f[j - k * v] + k * w);
}
System.out.println(f[m]);
}
}