mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 17:16:26 +00:00
P1507 NASA的食物计划
R41202952
This commit is contained in:
parent
c990d8bb2d
commit
89352b82f6
24
problem/P1507/P1507.cpp
Normal file
24
problem/P1507/P1507.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, u, v, w[505], z[505], c[505], f[55][505][505];
|
||||
|
||||
int main() {
|
||||
cin >> u >> v >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> w[i] >> z[i] >> c[i];
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = u; j > 0; j--) {
|
||||
for (int k = v; k > 0; k--) {
|
||||
f[i][j][k] = f[i - 1][j][k];
|
||||
if (j >= w[i] && k >= z[i]) {
|
||||
f[i][j][k] = max(f[i][j][k], f[i - 1][j - w[i]][k - z[i]] + c[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << f[n][u][v] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user