- 分组背包问题
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1000;
int w[maxn], v[maxn], f[maxn];
int main()
{int n, V;cin >> n >> V;for (int i = 0; i < n; i++){int m;cin >> m;for (int j = 0; j < n; j++){cin >> w[j] >> v[j];}for (int j = V; ~j; j--){for (int k = 0; k < m; k++){if (j - v[k] >= 0)//防止负号f[j] = max(f[j], f[j - v[k]] + w[k]);}}}cout<<f[m]<<endl;
}