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 ...
随机推荐
- Android消息传递之EventBus 3.0
Android消息传递之EventBus 3.0使用详解 http://www.cnblogs.com/whoislcj/p/5595714.html EventBus 3.0进阶:源码及其设计模式 ...
- HBase - 伪分布式安装过程
环境 - hadoop - 没有zookeeper(用hbase自带的zookeeper,当然后期我会改用独立的zookeeper) HBase介绍 参考:hbase是什么? hbase下载 地址:h ...
- 编译 ambari 2.7.3
官方给的教程比较简单,需要事先安装的工具也是这里列一点,那里列一点.在此记录一下编译要点(在 centos 7 下). 1. 事先需要安装的工具 yum install -y git svn node ...
- codevs3027(dp)
题目链接: http://codevs.cn/problem/3027/ 题意: 中文题目诶~ 思路: dp 先给所有线段按照右端点值升序 sort 一下, 用 dp[i] 存储以第 i 条线段结尾的 ...
- linux下redis的安装与django-redis使用方法
Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库.缓存和消息中间件. Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set( ...
- 百度判断手机终端并自动跳转uaredirect.js代码及使用实例
百度siteapp下的一款跳转的产品,使用起来很方便.你可以用这款JS跳转到手机版,也可以跳转到任何你想跳转的位置. js代码如下: function uaredirect(f) { try { if ...
- Go语言基础之9--指针类型详解
一. 变量和内存地址 每个变量都有内存地址,可以说通过变量来操作对应大小的内存 注意:通过&符号可以获取变量的内存地址 通过下面例子来理解下: 实例1-1 package main impor ...
- Java——flush()方法
Java在使用流时,缓冲区是一种发送数据的高效方法,但当溢出缓冲区的部分需要用flush()方法强制将数据发送出去,不必等到缓冲区再次装满,尤其是在数据量特别小的情况下,如果不使用此方法,很容易出现流 ...
- RequestContextHolder与RequestContextUtils
org.springframework.web.servlet.support.RequestContextUtils 在spring-webmvc中, 主要用来获取WebApplicationCon ...
- [2019BUAA软工]团队项目选择
Team V1 项目分析 写在前面 项目 内容 这个作业属于哪个课程 BUAA2019软件工程 这个作业的要求在哪里 团队项目选择 参考链接 如何提出靠谱的项目建议 NABCD 我们在这个课程的目标是 ...