类似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. WebApp与Native App有何区别

    转:http://blog.sina.com.cn/s/blog_5f2df1e401018hjj.html 今天看的一篇关于html5的Web App与Native App的技术分析,真的很棒分享一 ...

  2. LeetCode 17 Letter Combinations of a Phone Number (电话号码字符组合)

    题目链接 https://leetcode.com/problems/letter-combinations-of-a-phone-number/?tab=Description HashMap< ...

  3. 使用 udev 管理 Linux 设备文件

    本文以通俗的方法阐述 udev 及相关术语的概念.udev 的配置文件和规则文件,然后以 Red Hat Enterprise Server 为平台演示一些管理设备文件和查询设备信息的实例.本文会使那 ...

  4. ELK系列二:Elasticsearch的架构原理和配置优化

    1.Elasticsearch的数据组织架构 1.1.Elasticsearch结构概念 集群(cluster):拥有相同cluster-name的elasticsearch结点的集合(每个结点其实就 ...

  5. 【转】常用html转义符,JavaScript转义符

    HTML字符实体(Character Entities),转义字符串(Escape Sequence) 为什么要用转义字符串? HTML中<,>,&等有特殊含义(<,> ...

  6. 9.10Django模板

    2018-9-10 16:37:29 模板就一个 不能嵌套 模板:  http://www.cnblogs.com/liwenzhou/p/7931828.html 2018-9-10 21:23:3 ...

  7. POJ--1050--To the Max(线性动规,最大子矩阵和)

    To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 44723 Accepted: 23679 Descript ...

  8. windows10安装ubuntu16.04双系统

    因为科研需要,主要在ubuntu系统中进行学习开发,介绍一下安装windows10下安装ubuntu的经验. 1.工具 u盘(或者你也可以在你的硬盘中分出一部分FAT32的硬盘空间) Easyuefi ...

  9. Java编程思想中关于闭包的一个例子

    Java编程思想中的一个例子,不是很理解使用闭包的必要性,如果不使用闭包,是不是有些任务就不能完成?继续探索. package InnerClass; interface Incrementable ...

  10. POJ 2253 - Frogger - [dijkstra求最短路]

    Time Limit: 1000MS Memory Limit: 65536K Description Freddy Frog is sitting on a stone in the middle ...