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.

22 lines
625 B

#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;
}