B. Wizards and Huge Prize
time limit per test:

2 seconds

memory limit per test:

256 megabytes

input:

standard input

output:standard output

One must train much to do well on wizardry contests. So, there are numerous wizardry schools and magic fees.

One of such magic schools consists of n tours. A winner of each tour gets a huge prize. The school is organised quite far away, so one will have to take all the prizes home in one go. And the bags that you've brought with you have space for no more than k huge prizes.

Besides the fact that you want to take all the prizes home, you also want to perform well. You will consider your performance good if you win at least l tours.

In fact, years of organizing contests proved to the organizers that transporting huge prizes is an issue for the participants. Alas, no one has ever invented a spell that would shrink the prizes... So, here's the solution: for some tours the winner gets a bag instead of a huge prize. Each bag is characterized by number ai — the number of huge prizes that will fit into it.

You already know the subject of all tours, so you can estimate the probability pi of winning the i-th tour. You cannot skip the tour under any circumstances.

Find the probability that you will perform well on the contest and will be able to take all won prizes home (that is, that you will be able to fit all the huge prizes that you won into the bags that you either won or brought from home).

Input

The first line contains three integers nlk (1 ≤ n ≤ 200, 0 ≤ l, k ≤ 200) — the number of tours, the minimum number of tours to win, and the number of prizes that you can fit in the bags brought from home, correspondingly.

The second line contains n space-separated integers, pi (0 ≤ pi ≤ 100) — the probability to win the i-th tour, in percents.

The third line contains n space-separated integers, ai (1 ≤ ai ≤ 200) — the capacity of the bag that will be awarded to you for winning the i-th tour, or else -1, if the prize for the i-th tour is a huge prize and not a bag.

Output

Print a single real number — the answer to the problem. The answer will be accepted if the absolute or relative error does not exceed10 - 6.

Examples
input
3 1 0
10 20 30
-1 -1 2
output
0.300000000000
input
1 1 1
100
123
output
1.000000000000
Note

In the first sample we need either win no tour or win the third one. If we win nothing we wouldn't perform well. So, we must to win the third tour. Other conditions will be satisfied in this case. Probability of wining the third tour is 0.3.

In the second sample we win the only tour with probability 1.0, and go back home with bag for it.

题解

这大概是我第一道不是图上的概率

刚开始的时候都没有什么思路......果然dp还是要多刷题

我们设f[i][j][k]为"前i天赢了j场,剩余空间为k"的概率

通过十分艰苦地读题,不难发现,k在超过200后就没有什么用了,所以k只需要枚举0~200

但我们还发现这些比赛是无序的,也就是说我们可以先去拿后面的包,再去拿前面的奖,所以我们必须把它变成无序的.

考虑把k都加上200(诡异的思路......),这样前面的奖品也可以先选上(+200后是正的),再去后面选包,这样就可以随意处理了

这样最后在200<=k<=400,l<=j<=n的范围内枚举所有f[n][j][k]即可(现在的200意味着原来的0,小于200意味着剩余空间为负值)

代码见下:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=;
double p[N],k[N];
int n,l,s,b[N];
double f[N][N][*N];
int main()
{
scanf("%d%d%d",&n,&l,&s);
for(int i=;i<=n;i++)
scanf("%lf",&p[i]),p[i]/=,k[i]=1.0-p[i];
for(int i=;i<=n;i++)
{scanf("%d",&b[i]);}
f[][][s+]=;
for(int i=;i<n;i++)
for(int j=;j<=i;j++)
for(int v=;v<=;v++)
{
int t=min(v+b[i+],);
f[i+][j][v]+=f[i][j][v]*k[i+];
if(t>=)
f[i+][j+][t]+=f[i][j][v]*p[i+];
}
double ans=0.0;
for(int v=;v<=;v++)
for(int j=l;j<=n;j++)
ans+=f[n][j][v];
printf("%.12lf",ans);
}

codeforces167B

[codeforces167B]Wizards and Huge Prize的更多相关文章

  1. Codeforces Round #114 (Div. 1) B. Wizards and Huge Prize 概率dp

    B. Wizards and Huge Prize Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  2. [Codeforces-div.1 167B] Wizards and Huge Prize

    [Codeforces-div.1 167B] Wizards and Huge Prize 试题分析 注意到每个物品互相独立,互不干扰之后就非常好做了. 算出一个物品最后的价值期望,然后乘以K即可. ...

  3. Codeforces 167B Wizards and Huge Prize(概率dp)

    题意: n个人,开始有一个容量为k得背包,击败一个人背包可以获得一定容量或得到一个财富(放入背包内),给出击败每个人的概率,求至少击败l个人,且背包容量大于获得的总财富值的概率 分析: 状态好确定,d ...

  4. CodeForces 167B - Wizards and Huge Prize 期望概率dp

    初步分析:把赢了的巡回赛的a值加起来就是最后的剩余空间 这个明显的是状态转移的dp啊,然而他的状态比较骚是个数组,表示剩余空间,f(i,j,b),i表示比到第几场,j表示赢了几场,b就是里面的核心状态 ...

  5. Codeforces Round #114 (Div. 2)

    Codeforces Round #114 (Div. 2) 代码 Codeforces Round #114 (Div. 2) C. Wizards and Trolleybuses 思路 每条车的 ...

  6. The 2018 Nobel prizesThe Nobel prize for economics is awarded for work on the climate and economic growth

    The 2018 Nobel prizesThe Nobel prize for economics is awarded for work on the climate and economic g ...

  7. Huge Page 是否是拯救性能的万能良药?

    本文将分析是否Huge Page在任何条件下(特别是NUMA架构下)都能带来性能提升. 本博客已经迁移至: http://cenalulu.github.io/ 为了更好的体验,请通过此链接阅读: h ...

  8. FZU 1608 Huge Mission(线段树)

    Problem 1608 Huge Mission Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Description Oaiei ...

  9. Linux就这个范儿 第15章 七种武器 linux 同步IO: sync、fsync与fdatasync Linux中的内存大页面huge page/large page David Cutler Linux读写内存数据的三种方式

    Linux就这个范儿 第15章 七种武器  linux 同步IO: sync.fsync与fdatasync   Linux中的内存大页面huge page/large page  David Cut ...

随机推荐

  1. Typecho - MyTagCloud标签云插件

    一.前言: 标签云是博客.CMS类系统的常见功能,读者可以根据标签快速的查找和浏览自己喜欢的文章.个人很喜欢Typecho的简洁,但对于后台不能控制前台标签栏目的显示还是略表遗憾.令人高兴的是Type ...

  2. angular2项目添加ng2-bootstrap

    1. 先webstome创建一个空的工程.例如test File--> New -->Project --> Empty Project 2.然后命令行(Alt+F12)下执行以下命 ...

  3. Linux图形界面与字符界面切换

    1. 启动时进入字符界面,后来想切换到图形界面:使用startx 或 init 5 (注:startx只是在原有运行级别3上加了图形界面,运行级别没变,而init 5 则是切换到运行级别5,所以要重新 ...

  4. Linux系统档案与文件系统的压缩与打包

    以下文章基于centos6.5 文章引自:http://www.jb51.net/LINUXjishu/105916.html 一.Linux下常见的压缩指令 在linux的环境中,压缩文件的扩展名大 ...

  5. Java (PO,VO,DAO,BO,POJO,DTO) 几种对象解释

    1. PO:persistant object 持久对象 可以看成是与数据库中的表相映射的java对象.最简单的PO就是对应数据库中某个表中的一条记录,多个记录可以用PO的集合.PO中应该不包含任何对 ...

  6. JDK版本会影响项目部署

    最近在公司里面部署javaweb项目的时候,项目启动的时候报错,我使用了各种方法来寻找答案,将近花了很长的时间.就在今天我终于找到了问题的根源,我开始用的是JDK1.8的版本,换了一个1.7版本的JD ...

  7. PHP 中级内容

    1.面向对象编程(OOP) 2.模板引擎(smarty) 3.MYSQL(中级操作) 数据库抽象层(PDO): 4.Ajax(异步刷新) 5.Js框架(jQuery) Xml+JSON数据       ...

  8. 16、Collection接口及其子接口Set和List(常用类LinkedList,ArrayList,Vector和Stack)

    16.Collection接口 Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements).一些Collection允许相同 ...

  9. 分辨率、像素和PPI

    屏幕尺寸是指屏幕对角线的长度,一般以英寸为单位,1英寸(inch)=2.54厘米(cm).传统意义上的照片尺寸也是这个概念.所以同样尺寸(指对角线)的屏幕,也可能长宽比率不同.像素(Pixel):是位 ...

  10. 用app.net Core搞点多国语言网站

    Asp.net Core 中文文档很少,你可以看英文的,不过英文的也是说的有点乱.这篇文章是干货. 1. 配置好你的WebApplication,使他可以支持国际化语言,修改文档Startup.cs ...