uva 10163 Storage Keepers
来源:互联网 发布:java反射获取私有属性 编辑:程序博客网 时间:2024/05/16 15:50
import java.io.*;import java.math.BigInteger;import java.util.*;class problem1{ String s1,s2,s3; void solver() throws IOException{ Scanner scan = new Scanner(System.in); while(true){ int n=scan.nextInt(); int m=scan.nextInt(); if(n==0) break; int arr[] = new int[m+1]; for(int i=1;i<=m;i++) arr[i]=scan.nextInt(); int dp[][] = new int[n+1][m+1]; Arrays.fill(dp[0], 9999999); int money[][] = new int[n+1][m+1]; for(int i=1;i<=n;i++) money[i][0]=9999999; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ dp[i][j]=dp[i][j-1]; for(int k=0;k<i;k++){ dp[i][j]=Math.max(dp[i][j], Math.min(dp[k][j-1], arr[j]/(i-k))); } } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ money[i][j]=money[i][j-1]; for(int k=0;k<i;k++){ if(arr[j]/(i-k)>=dp[n][m]){ money[i][j]=Math.min(money[i][j], money[k][j-1]+arr[j]); } } } } //Dumper.print_2_arr(dp, n+1, m+1); //Dumper.print_2_arr(money, n+1, m+1); if(dp[n][m]==0) System.out.println(0+" "+0); else System.out.println(dp[n][m]+" "+money[n][m]); } }}public class test { public static void main (String [] args) throws Exception { problem1 p = new problem1(); p.solver(); }}
这个题目的工资部分搞不出来。。。
最大安全度还是比较好想的,从前i个产品扒K个出来给第j个人看管,然后K可以取0到i,就是全部给j管或者j被忽略
K==I的时候由于除数是0,这个情况写在外面
工资部分我一直在想找最小值,其实不是,这个要DP的。
保留的值是当前最优安全度下的最小值,但是当前最优安全度很可能是大于全局安全度的
所以当前最优工资是没有意义的。。。又跳坑出不来,没想到这个要DP。
0 0
- uva 10163 Storage Keepers
- UVA 10163 Storage Keepers
- UVA 10163 Storage Keepers
- UVA - 10163 Storage Keepers
- uva 10163 Storage Keepers
- UVA 10163 - Storage Keepers
- uva 10163 Storage Keepers
- UVA - 10163 Storage Keepers
- UVa 10163 Storage Keepers
- UVA - 10163 Storage Keepers
- UVA 10163 Storage Keepers
- Storage Keepers - UVa 10163 dp
- UVA 10163 - Storage Keepers(dp)
- UVA 10163 - Storage Keepers(dp)
- UVA 10163 Storage Keepers(dp + 背包)
- uva 10163 - Storage Keepers(01背包)
- UVA - 10163Storage Keepers(01背包)
- uva 10163 Storage Keepers (dp)
- android 怎么引用Libray
- 电脑内存常见问题处理方法
- c#在WinForms程序里实现窗体传值的最佳实践
- 【js学习笔记-092】-----事件处理程序的调用
- 【ios】NSPredicate使用总结
- uva 10163 Storage Keepers
- 我与GitHub的第一次——自制音乐文件修改器
- Dom4j 使用简介
- Oracle正则表达式的应用
- 线程间共享数据
- enlightened landscape
- 软妹子之心,智能硬汉子们可懂?
- Linux的五个查找命令
- 表闪回,可用于恢复数据或者查询以前的数据