/*
* @Description: To iterate is human, to recurse divine.
* @Autor: Recursion
* @Date: 2022-04-03 10:45:34
* @LastEditTime: 2022-04-03 10:59:29
*/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;
const int N = 401;
int V,W;
int n;
int v[N],w[N],c[N];//体积 重量 卡路里
int dp[N][N];
void read()
{
cin >> V >> W;
cin >> n;
for(int i = 1;i <= n;i ++)
cin >> v[i] >> w[i] >> c[i];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
read();
for(int i = 1;i <= n;i ++){
for(int j = V;j >= v[i];j --)
for(int k = W;k >= w[i];k --)
dp[j][k] = max(dp[j - v[i]][k - w[i]] + c[i],dp[j][k]);
}
cout << dp[V][W] << endl;
return 0;
}
P1507 NASA的食物计划
最新推荐文章于 2024-07-07 15:41:43 发布