'commit'
This commit is contained in:
22
TangDou/BeiBao/bb01ErWeiFeiYong.cpp
Normal file
22
TangDou/BeiBao/bb01ErWeiFeiYong.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 1010;
|
||||
const int M = 110;
|
||||
int n, V, W;
|
||||
int v1[N], v2[N], w[N];
|
||||
int f[N][M][M];
|
||||
|
||||
int main() {
|
||||
cin >> n >> V >> W;
|
||||
for (int i = 1; i <= n; i++) cin >> v1[i] >> v2[i] >> w[i];
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 0; j <= V; j++)
|
||||
for (int k = 0; k <= W; k++)
|
||||
if (j < v1[i] || k < v2[i])
|
||||
f[i][j][k] = f[i - 1][j][k];
|
||||
else
|
||||
f[i][j][k] = max(f[i - 1][j - v1[i]][k - v2[i]] + w[i], f[i - 1][j][k]);
|
||||
printf("%d", f[n][V][W]);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user