constint N = 1010; int n, m; int v[N], w[N]; int f[N];
intmain() { cin>> n >> m; for (int i = 1; i <= n; i++)cin >> v[i] >> w[i]; for (int i = 1; i <= n; i ++) for (int j = v[i]; j <=m; j++) f[j] = max(f[j], f[j-v[i]] + w[i]); cout << f[n] << endl; return0; }
constint N = 110; int v[N], w[N], s[N]; int f[N][N]; int n, m; intmain() { cin >> n>> m; for (int i = 1; i <= n; i ++) cin >>v[i]>> w[i] >>s[i]; for (int i = 1; i <= n; i ++) //枚举背包 for(int j = 1; j <= m; j ++) // 枚举体积 for (int k = 0; k <= s[i] && k *v[i] <= j; k ++) f[i][j] = max(f[i][j], f[i - 1][j - v[i] * k] + w[i] * k); cout << f[n][m] << endl; return0; }
intmain() { cin >> n >> m; int cnt = 0; for (int i = 1 ; i <= n; i ++) { int a, b, s; cin >> a>> b >> s; int k = 1; while(k <= s) { cnt ++; v[cnt] = a * k; w[cnt] = b * k; s -= k; k *= 2; } if (s > 0) { cnt ++; v[cnt] = a * s; w[cnt] = b * s; } } n = cnt; for (int i = 1; i <=n; i ++) for (int j = m; j >= v[i]; j --) f[j] = max(f[j], f[j - v[i]] + w[i]); cout << f[m] << endl; return0; }