B. Wizards and Huge Prize

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/167/problem/B

Description

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.

 

Sample Input

3 1 0
10 20 30
-1 -1 2

Sample Output

0.300000000000

HINT

题意

有n个人,你需要至少打败l个人,你一开始的背包容量是k

打败每个人的概率是p[i],如果a[i]=-1,那么说明这个人打败之后,会给你奖品,否则就会给你一个容量为a[i]的背包

每个奖品带回家,都需要容量为1的背包

问你至少打败l个人,并且把胜利品全部都能带回去的概率是多少

题解:

dp[i][j][k]表示我目前挑战到第i个人,打败了j个人,我把所有胜利品都背回去之后的背包剩余容量为k

然后转移转移就好了~

代码:

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std; int tmp = ;
double dp[][][];
double p[];
int a[];
int main()
{
int n,l,k;
scanf("%d%d%d",&n,&l,&k);
for(int i=;i<=n;i++)
{
scanf("%lf",&p[i]);
p[i]/=100.0;
}
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
dp[][][tmp+k]=;
for(int i=;i<n;i++)
{
for(int j=;j<=i;j++)
{
for(int t=;t<=;t++)
{
if(a[i+]==-)
{
if(t>)dp[i+][j+][t-] += dp[i][j][t] * p[i+];
dp[i+][j][t] += dp[i][j][t]*(-p[i+]);
}
else
{
int pl = min(t + a[i+],);
dp[i+][j+][pl] += dp[i][j][t]*p[i+];
dp[i+][j][t] += dp[i][j][t]*(-p[i+]);
}
}
}
}
double ans = ;
for(int i=l;i<=n;i++)
for(int j=tmp;j<=;j++)
ans += dp[n][i][j];
printf("%.10f\n",ans);
}

Codeforces Round #114 (Div. 1) B. Wizards and Huge Prize 概率dp的更多相关文章

  1. Codeforces Round #114 (Div. 1) A. Wizards and Trolleybuses 物理题

    A. Wizards and Trolleybuses Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  2. Codeforces Round #114 (Div. 1) D. Wizards and Roads 笛卡尔树+树贪心+阅读题

    D. Wizards and Roads 题目连接: http://www.codeforces.com/contest/167/problem/D Description In some count ...

  3. Codeforces Round #114 (Div. 1) E. Wizards and Bets 高斯消元

    E. Wizards and Bets 题目连接: http://www.codeforces.com/contest/167/problem/E Description In some countr ...

  4. Codeforces Round #114 (Div. 1) C. Wizards and Numbers 博弈论

    C. Wizards and Numbers 题目连接: http://codeforces.com/problemset/problem/167/C Description In some coun ...

  5. Codeforces Round #284 (Div. 1) B. Name That Tune(概率DP)(难)

    B. Name That Tune time limit per test 1 second memory limit per test 256 megabytes input standard in ...

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

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

  7. Codeforces Round #114 (Div. 2)

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

  8. Codeforces Round #396 (Div. 2) A B C D 水 trick dp 并查集

    A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...

  9. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

随机推荐

  1. Buffer cache 的调整与优化

    Buffer cache 的调整与优化 -============================== -- Buffer cache 的调整与优化(一) --==================== ...

  2. js除法余数

    return (Math.round(rs*100)/100); //保保留小数点后两位数: //如果要保留三位则改为:Math.round(rs*1000)/1000; //如果要保留四位则改为:M ...

  3. HDU 5744 Keep On Movin

    Keep On Movin Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  4. codedorces 260 div2 A题

    水题,扫描一遍看是否出现价格低质量高的情况. #include<cstdio> #include<string> #include<vector> #include ...

  5. Java进程占用CPU资源过多分析

    问题描述: 生产环境下的某台tomcat7服务器,在刚发布时的时候一切都很正常,在运行一段时间后就出现CPU占用很高的问题,基本上是负载一天比一天高. 问题分析: 1,程序属于CPU密集型,和开发沟通 ...

  6. RockMongo安装使用笔记

    下载nginx最新版本下载PHP,5.X版本即可,非线程安全的的,因为nginx用的是fastcgi下载rockmongo最新版本下载php_mongo组件 在rockmongo里的readme里有下 ...

  7. div模拟的下拉框特效jquery

    从网上找来的,感觉不错就拿来分享下 <style type="text/css"> body, ul, li { margin: 0; padding: 0; font ...

  8. C++ 我想这样用(三)

    话接前篇,继续谈在C++环境下使用C风格编程时的注意点: 6.关于原型的声明 在C里,调用一个未声明的函数是允许的,但是在C++里,必须先声明才能调用函数.另外,如果函数的参数是空的,那么在c里面是未 ...

  9. 将“Cocos2dx-截屏并设置图片尺寸 ”中cocos2d-x代码转换为2.2的代码

    Cocos2dx-截屏并设置图片尺寸: http://www.cocos2dev.com/?p=522 2.2 代码如下: void HelloWorld::screenShoot() { CCSiz ...

  10. Spring MVC MultiActionController example

    In Spring MVC application, MultiActionController is used to group related actions into a single cont ...