#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <cmath>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int MN = 65005;
const int MAXN = 1000005;
const int INF = 0x3f3f3f3f;
#define reg register
#define IOS ios::sync_with_stdio(false)
int V, M, n;
int v[MAXN];
int m[MAXN];
int ka[MAXN];
int dp[500][500];
int main() {
scanf("%d %d", &V, &M);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d %d %d", v + i, m + i, ka + i);
}
for (int i = 1; i <= n; i++) {
for (int j = V; j >= v[i]; j--) {
for (int k = M; k >= m[i]; k--) {
dp[j][k] = max(dp[j][k], dp[j - v[i]][k - m[i]] + ka[i]);
}
}
}
printf("%d", dp[V][M]);
return 0;
}
P1507 NASA的食物计划(二维01背包)
最新推荐文章于 2024-03-04 20:35:43 发布