class Solution {
public:
/**
*
* @param breadNum int整型
* @param beverageNum int整型
* @param packege int整型vector<vector>>> 每个一维数组中有三个数,依次表示这个包装里面的面包数量、饮料数量、花费
* @return int整型
*/
int minCost(int breadNum, int beverageNum, vector<vector<int> >& packageSum) {
// write code here
vector<vector<int> > dp(breadNum+1, vector<int>(beverageNum+1, 0x3f3f3f));
dp[0][0] = 0;
int k = packageSum.size();
if (k == 0) return 0;
for (int i = 0; i < k; i ++) {
for (int j = breadNum; j >= 0; j --) {
for (int t = beverageNum; t >= 0; t--) {
int j1 = j + packageSum[i][0];
int t1 = t + packageSum[i][1];
if (j1 > breadNum) j1 = breadNum;
if (t1 > beverageNum) t1 = beverageNum;
dp[j1][t1] = min (dp[j][t] + packageSum[i][2], dp[j1][t1]);
}
}
}
return dp[breadNum][beverageNum];
}
};