You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
932 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
#define maxV 1000
/**
* 2.
1
nv
ic[i]w[i]
使
2
ncivi
*/
int main(void) {
int cases, n, v, ci, wi;
int f[maxV];
freopen("../2.txt", "r", stdin);
cin >> cases;
while (cases--) {
memset(f, 0, sizeof(f));
cin >> n >> v;
for (int i = 0; i < n; i++) {
cin >> ci >> wi;
for (int j = 0; j <= v; j++) {
if (j >= ci)
f[j] = max(f[j], f[j - ci] + wi);
}
}
cout << f[v] << endl;
}
}