LintCode(M)背包问题2
来源:互联网 发布:郁可唯 独家记忆 知乎 编辑:程序博客网 时间:2024/05/20 04:48
public class Solution { /** * @param m: An integer m denotes the size of a backpack * @param A & V: Given n items with size A[i] and value V[i] * @return: The maximum value */ public int backPackII(int m, int[] A, int V[]) { // write your code here int bb[][]=new int[A.length][m+1],i=0,j=0; //bb[][0] for (i = 0; i < A.length ; ++i) { bb[i][0] = 0; } //bb[][] for (j = 1; j <m + 1; ++j){ if (A[0]>j) bb[0][j] = 0; else bb[0][j] = V[0]; for (i = 1; i <A.length ; ++i){ if (A[i]>j) bb[ i][j] = bb[i - 1][j]; else bb[i][j] = Math.max(bb[i - 1][j], bb[i - 1][j - A[i]] + V[i]); } } return bb[A.length-1][m]; }}
0 0
- LintCode(M)背包问题2
- LintCode(M)背包问题
- LintCode:M-背包问题 II
- LintCode-背包问题 II
- 【LintCode】Backpack 背包问题
- lintcode-背包问题-92
- LintCode : 背包问题 II
- LintCode :背包问题
- LintCode : 背包问题 II
- lintcode backpack 背包问题
- LintCode:背包问题
- LintCode:背包问题 II
- LintCode:背包问题
- LintCode:01背包问题
- LintCode 62-背包问题
- LintCode 背包问题
- 背包问题-LintCode
- Lintcode 背包问题
- iOS 实现扫码时周边模糊中间清晰的效果
- 并行计算评价指标
- 宽屏banner切换jquery
- 从零开始学习jQuery (四) 使用jQuery操作元素的属性与样式
- 一个IT菜鸟的自白
- LintCode(M)背包问题2
- ios 关于textfield(1)
- tomcat配置https服务器
- Java游戏服务器端面试题整理(转载)
- 从零开始学习jQuery (五) 事件与事件对象
- 值得推荐的C/C++框架和库
- 好玩的adb
- HBase Split分析
- 从零开始学习jQuery (六) AJAX快餐