hduoj 2955Robberies
Robberies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16726 Accepted Submission(s): 6165
For a few months now, Roy has been assessing the security of various banks and the amount of cash they hold. He wants to make a calculated risk, and grab as much money as possible.His mother, Ola, has decided upon a tolerable probability of getting caught. She feels that he is safe enough if the banks he robs together give a probability less than this.
Notes and Constraints 0 < T <= 100 0.0 <= P <= 1.0 0 < N <= 100 0 < Mj <= 100 0.0 <= Pj <= 1.0 A bank goes bankrupt if it is robbed, and you may assume that all probabilities are independent as the police have very low funds.
0.04 3
1 0.02
2 0.03
3 0.05
0.06 3
2 0.03
2 0.03
3 0.05
0.10 3
1 0.03
2 0.02
3 0.05
4
6
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 1e-8
int cost[];
double p[],dp[];
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int t,bn,i,sum;
double pro;
scanf("%d",&t);
while(t--){
sum=;
//memset(dp,0,sizeof(dp));
scanf("%lf %d",&pro,&bn);
pro=-pro;//不被抓的概率大于才有效
for(i=;i<bn;i++){
scanf("%d %lf",&cost[i],&p[i]);
sum+=cost[i];
p[i]=-p[i];
}
for(i=;i<=sum;i++){
dp[i]=;
}
dp[]=;
int j;
for(i=;i<bn;i++){
for(j=sum;j>=cost[i];j--){
//得到j钱,最大的不被抓的可能性
dp[j]=max(dp[j],dp[j-cost[i]]*p[i]);
}
}
for(j=sum;j>=;j--){
if(dp[j]-pro>inf){
break;
}
}
printf("%d\n",j);
}
return ;
}
hduoj 2955Robberies的更多相关文章
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- hdu-oj 1874 畅通工程续
最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...
- C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...
- C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...
- HDUOJ题目HTML的爬取
HDUOJ题目HTML的爬取 封装好的exe/app的GitHub地址:https://github.com/Rhythmicc/HDUHTML 按照系统选择即可. 其实没什么难度,先爬下来一个题目的 ...
- hduoj 1251 统计难题
http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory ...
- hduoj 1286 找新朋友
http://acm.hdu.edu.cn/showproblem.php?pid=1286 找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
随机推荐
- C# 与Java初始化顺序及异同(转)
C#初始化顺序 类成员变量初始化先于类的构造函数 静态成员变量先于实例变量 子类成员变量先于父类成员变量(java相反) 父类构造函数先于子类构造函数 参考实例: using System; //us ...
- console的使用
一.显示信息的命令 console.log("normal"); // 用于输出普通信息 console.info("information"); // 用于输 ...
- phpstrom 下载及phpStudy环境配置
1.下载phpstudy 2.打开 3. 4. 5.网站网址 项目路径 新增 host映射 PHP富文本编辑器 6.https://jingyan.baidu.com/articl ...
- anularjs前端分页
var dataList = []; $scope.page = { page:1, pageSize:15, numPerPageOpt:[15,30,50,100], totalNum:0, to ...
- C#WinForm POST方式提交给网页(与网页交互) (转)
提交(POST): 需要导入命名空间: using System.Net;using System.IO; string postData = "username=" + Logi ...
- maven 项目 配置docker镜像生成(dockerfile-maven-plugin)
插件地址:https://github.com/spotify/dockerfile-maven 依github上备注,只要在项目根上录上编写dockerfile,然后引用插件即可 编写Dockerf ...
- 【笔记】Django的ORM之删和改
[笔记]Django的ORM之删和改 Django ORM 数据库 一 删除操作 1.视图层 <table border="1"> <thead> < ...
- Oulipo (KMP出现次数)
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...
- 2015苏州大学ACM-ICPC集训队选拔赛(1) 1008
猪猪过河 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submissi ...
- css兼容写法
css3 1.box-shadow: filter:progid:DXImageTransform.Microsoft.Shadow(color=#,direction=,strength=);/*兼 ...