类似BackpackII问题

     static int maximize_loot(int[] gold, int[] silver) {
int[][] res = new int[gold.length+silver.length+1][10001];
res[0][0] = 0;
for (int i=1; i<=gold.length; i++) {
for (int j=0; j<=10000; j++) {
res[i][j] = Math.max(res[i-1][j], (j>=gold[i-1]? res[i-1][j-gold[i-1]]+10*gold[i-1] : 0));
}
}
for (int i=1; i<=silver.length; i++) {
for (int j=0; j<=10000; j++) {
res[i+gold.length][j] = Math.max(res[i+gold.length-1][j], (j>=silver[i-1]? res[i+gold.length-1][j-silver[i-1]]+1*silver[i-1] : 0));
}
}
int maxVal = 0;
for (int k=0; k<=10000; k++) {
maxVal = Math.max(maxVal, res[gold.length+silver.length][k]);
}
return maxVal; }

VMware Coding Challenge: The Heist的更多相关文章

  1. VMware Coding Challenge: Removing Duplicates Entries

    static LinkedListNode removeDuplicates(LinkedListNode list) { LinkedListNode cur = list; HashSet< ...

  2. VMware coding Challenge: Coin Toss Betting

    static int CoinTossEndAmount(int betAmount, String coinTossResults) { if (betAmount <=0 || coinTo ...

  3. VMware coding Challenge:Date of Weekday

    这道题再次证明了这种细节的题目,画个图容易搞清楚 import java.util.Scanner; public class Solution2 { static int DateOfWeekday ...

  4. VMware Coding Challenge: Possible Scores && Summary: static

    Combination Sum I 那道题的变体 /* * Complete the function below. */ static int is_score_possible(int score ...

  5. VMware coding Challenge

    思路:这道题要观察,举个例子,1 2 * * 3 * 4  5 * * 6 7 * 8 * *, 用Stack,先序遍历,遇到数字就入栈,如果遇到 * *,说明栈顶节点是叶子节点,一条根到叶子的路径这 ...

  6. poj-2514-模拟

    http://poj.org/problem?id=2514 Ridiculous Addition Time Limit: 1000MS   Memory Limit: 65536K Total S ...

  7. amazon interview

    I'll be sitting for an Amazon interview in 3 months. Which website should I use to practice: SPOJ, H ...

  8. 22. CTF综合靶机渗透(十五)

    靶机说明: Game of Thrones Hacking CTF This is a challenge-game to measure your hacking skills. Set in Ga ...

  9. 24 Days Of JavaScript mas

    24 Days Of JavaScript mas Level up your JavaScript skills with a daily coding challenge from Decembe ...

随机推荐

  1. window下node更新

    打开cmd查看你之前node版本安装的路径,where node: 直接去官网下载与你电脑系统(32位还是64位)对应的最新的mis版本,安装在上述路径中覆盖即可. 注意:windows上并不支持n模 ...

  2. Linux系统启动内幕

    经过对Linux系统有了一定了解和熟悉后,想对其更深层次的东西做进一步探究.这当中就包括系统的启动流程.文件系统的组成结构.基于动态库和静态库的程序在执行时的异同.协议栈的架构和原理.驱动程序的机制等 ...

  3. zabbix-proxy配置

    1,proxy配置 # cat /etc/zabbix/zabbix_proxy.conf Server=192.168.1.1 Hostname=proxy.com LogFile=/tmp/zab ...

  4. ES6 阮一峰阅读学习

    参考: ECMAScript6入门 就是随便看看,了解一下. 一.ECMAScript6简介 1. 什么是ECMAScript6? JavaScript语言的下一代标准.2015年6月发布,正式名称是 ...

  5. Unity3D笔记十五 碰撞、移动

    碰撞 Collision. [kəˈliʒən] 碰撞:冲突:(意见,看法)的抵触:(政党等的)倾轧 选择一个需要添加碰撞器的游戏对象后 Component->Physics- Unity一共为 ...

  6. Spring Cloud Eureka 配置

    实例名配置       在Netflix Eureka的原生实现中,实例名采用主机名作为默认值,这样的设置使得在同一主机上无法启动多个相同的实例,所以在Spring Cloud Eureka的配置中, ...

  7. 这个代码给所有带有name属性的链接加了一个背景色

    jQuery起点教程之使用选择器和事件jQuery提供两种方式来选择html的elements: 第一种是用CSS和Xpath选择器联合起来形成一个字符串来传送到jQuery的构造器(如:$(&quo ...

  8. POJ-1322 Chocolate(概率DP)

    Chocolate Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9279 Accepted: 2417 Special Jud ...

  9. HDU 4578 - Transformation - [加强版线段树]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 Problem Description Yuanfang is puzzled with the ...

  10. 2018牛客网暑期ACM多校训练营(第四场) A - Ternary String - [欧拉降幂公式][扩展欧拉定理]

    题目链接:https://www.nowcoder.com/acm/contest/142/A 题目描述 A ternary string is a sequence of digits, where ...