VMware Coding Challenge: The Heist
VMware The Coding
2023-09-11 14:14:07 时间
类似BackpackII问题
1 static int maximize_loot(int[] gold, int[] silver) { 2 int[][] res = new int[gold.length+silver.length+1][10001]; 3 res[0][0] = 0; 4 for (int i=1; i<=gold.length; i++) { 5 for (int j=0; j<=10000; j++) { 6 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)); 7 } 8 } 9 for (int i=1; i<=silver.length; i++) { 10 for (int j=0; j<=10000; j++) { 11 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)); 12 } 13 } 14 int maxVal = 0; 15 for (int k=0; k<=10000; k++) { 16 maxVal = Math.max(maxVal, res[gold.length+silver.length][k]); 17 } 18 return maxVal; 19 20 }
相关文章
- AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
- 启动vmware中的虚拟机的时候,提示Failed to lock the file
- 解决Maven打包时报错"The packaging for this project did not assign a file to the build artifact"
- 虚拟化(二):虚拟化及vmware workstation产品使用
- hyper-v启动虚拟机时提示“The application encountered an error while attempting to change the state of the machine ‘虚拟机名称'”如何处理?
- The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be Uuid
- 继承“HibernateDaoSupport”后,报“The hierarchy of the type AccoutDaoImpl is inconsistent”的解决方案
- vmware Unable to open kernel device ".Globalvmx86": The system cannot find the file 的解决方法
- 《VMware vSphere 6.0虚拟化架构实战指南》——第1章 软件定义数据中心 1.1 传统数据中心介绍
- 《VMware vSphere 6.0虚拟化架构实战指南》——2.3 安装VMware ESXi 6.0
- 《精通VMware vSphere 6》——第2章 规划与安装 VMware ESXi 2.1规划VMware vSphere部署
- 【解决方案】ERROR: lib/bridge_generated.dart:837:9: Error: The parameter ‘ptr‘ of the method ‘FlutterRustB
- 安卓的开发者都应该看的一本新书,解密Android操作系统背景《Androids: The Team That Built the Android Operating System》
- Input and Output-The input is all the sources of action for your app
- 《VMware vCAT权威指南:成功构建云环境的核心技术和方法》一第2章 服 务 定 义2.1 概述
- 《VMware 网络技术:原理与实践》—— 1.3 小结
- VMware中国的“七年之痒”,真的会有大动荡吗?
- 目标电信运营商市场,VMware的战车全速前进
- Unity 报错之 The same field name is serialized multiple times in the class or its parent class.
- suseoj The wheat of the prime minister
- VMWare中新建Linux虚拟机