Robberies

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16726    Accepted Submission(s): 6165

Problem Description
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the lucrative business of bank robbery only for a short while, before retiring to a comfortable job at a university.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.
 
Input
The first line of input gives T, the number of cases. For each scenario, the first line of input gives a floating point number P, the probability Roy needs to be below, and an integer N, the number of banks he has plans for. Then follow N lines, where line j gives an integer Mj and a floating point number Pj . Bank j contains Mj millions, and the probability of getting caught from robbing it is Pj .
 
Output
For each test case, output a line with the maximum number of millions he can expect to get while the probability of getting caught is less than the limit set.
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.
 
Sample Input
3
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
 
Sample Output
2
4
6
 
Source
 
Recommend
gaojie   |   We have carefully selected several similar problems for you:  1203 2159 2844 1171 1864 
 #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的更多相关文章

  1. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

  2. 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 ...

  3. 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 ...

  4. hdu-oj 1874 畅通工程续

    最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...

  5. C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...

  6. C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...

  7. HDUOJ题目HTML的爬取

    HDUOJ题目HTML的爬取 封装好的exe/app的GitHub地址:https://github.com/Rhythmicc/HDUHTML 按照系统选择即可. 其实没什么难度,先爬下来一个题目的 ...

  8. hduoj 1251 统计难题

    http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory ...

  9. hduoj 1286 找新朋友

    http://acm.hdu.edu.cn/showproblem.php?pid=1286 找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...

随机推荐

  1. C#.Net使用正则表达式抓取百度百家文章列表

    工作之余,学习了一下正则表达式,鉴于实践是检验真理的唯一标准,于是便写了一个利用正则表达式抓取百度百家文章的例子,具体过程请看下面源码: 一:获取百度百家网页内容 public List<str ...

  2. C# DLL(程序集)的生成和调用

    日期:2018年11月24日 环境:Window 10,VS2015 一.利用VS2015自带的工具生成DLL 步骤: 1.利用C#准备一个.cs文件: using System; public cl ...

  3. U-Net: Convolutional Networks for Biomedical Image Segmentation(理解+github代码)

    github代码:https://github.com/Chet1996/pytorch-UNet 0 - Abstract 这篇文章是生物学会议ICMICCAI2015的文章,主要针对的是生物影像进 ...

  4. 「BZOJ 1831」「AHOI 2008」逆序对「贪心」

    题意 给定一个长度为\(n\),值域为\([1,k]\),某些位置不确定的数组,求最小的逆序对.\(n\leq 10^4, k \leq 100\) 题解 这题有人用前缀和优化\(dp\)过了,但是这 ...

  5. 服务器部署php项目

    windows服务器   首先打开开始菜单,点击运行.   然后输入mstsc,确定   输入你的服务器IP,点击连接   这里选择 是   然后就到了登录界面,输入用户名和密码就可以了 linux服 ...

  6. Ready api groovy script 参数化

    def token_type =context.expand ('${#Project#token_type}') def access_token = context.expand('${#Proj ...

  7. Bridge Across Islands POJ - 3608 旋转卡壳求凸包最近距离

    \(\color{#0066ff}{题目描述}\) 几千年前,有一个小王国位于太平洋的中部.王国的领土由两个分离的岛屿组成.由于洋流的冲击,两个岛屿的形状都变成了凸多边形.王国的国王想建立一座桥来连接 ...

  8. 平衡树学习笔记(2)-------Treap

    Treap 上一篇:平衡树学习笔记(1)-------简介 Treap是一个玄学的平衡树 为什么说它玄学呢? 还记得上一节说过每个平衡树都有自己的平衡方式吗? 没错,它平衡的方式是......rand ...

  9. P1900 自我数

    题意: 对于每一个正整数n,我们定义d(n)为n加上它每一位数字的和. 例如,d(75)=75+7+5=87.给定任意正整数n作为一个起点,都能构造出一个无限递增的序列:n, d(n), d(d(n) ...

  10. 数据结构1:数据结构与算法C语言版分析概述

    本节开始将带领大家系统地学习数据结构,作为一门计算机专业大二学生的必修课程,该课程面对的目标人群为初步具备基本编程能力和编程思想的程序员(大一接触了 C 语言或者 C++).通过系统地学习数据结构,可 ...