0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 14:18:47 +00:00
Baoshuo Ren 2022-04-06 16:24:47 +08:00
parent 5d654e6b47
commit dd0c2a1704
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
3 changed files with 45 additions and 0 deletions

39
AcWing/9/9.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <cstring>
#include <iostream>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
int n, m, s[N], v[N][N], w[N][N], f[N];
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> s[i];
for (int j = 1; j <= s[i]; j++) {
cin >> v[i][j] >> w[i][j];
}
}
memset(f, 0xcf, sizeof(f));
f[0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = m; j >= 0; j--) {
for (int k = 1; k <= s[i]; k++) {
if (j >= v[i][k]) {
f[j] = std::max(f[j], f[j - v[i][k]] + w[i][k]);
}
}
}
}
cout << f[m] << endl;
return 0;
}

BIN
AcWing/9/data/2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AcWing/9/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.