A11137 | Expected Earnings
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are playing a game with a bag of red and black balls. Initially, you are told that the bag has $n$ balls total. In addition, you are also told that the bag has probability $p_{i}/10^{6}$ of containing exactly $i$ red balls.
You now would like to buy balls from this bag. You really like the color red, so red balls are worth a unit of $1$ , while black balls are worth nothing. To buy a ball, if there are still balls in the bag, you pay a cost $c$ with $0<=c<=1$ , and draw a ball randomly from the bag. You can choose to stop buying at any point (and you can even choose to not buy anything at all).
Given that you buy optimally to maximize the expected profit (i.e. # red balls - cost needed to obtain them), print the maximum expected profit.
You now would like to buy balls from this bag. You really like the color red, so red balls are worth a unit of $1$ , while black balls are worth nothing. To buy a ball, if there are still balls in the bag, you pay a cost $c$ with $0<=c<=1$ , and draw a ball randomly from the bag. You can choose to stop buying at any point (and you can even choose to not buy anything at all).
Given that you buy optimally to maximize the expected profit (i.e. # red balls - cost needed to obtain them), print the maximum expected profit.
输入格式
The first line of input will contain two integers $n,X$ ( $1<=n<=10000$ , $0<=X<=10^{6}$ ).
The next line of input will contain $n+1$ integers $p_{0},p_{1},...\ p_{n}$ ( $0<=p_{i}<=10^{6}$ , )
The value of $c$ can be computed as .
The next line of input will contain $n+1$ integers $p_{0},p_{1},...\ p_{n}$ ( $0<=p_{i}<=10^{6}$ , )
The value of $c$ can be computed as .
输出格式
Print a single floating point number representing the optimal expected value.
Your answer will be accepted if it has absolute or relative error at most $10^{-9}$ . More specifically, if your answer is $a$ and the jury answer is $b$ , your answer will be accepted if .
Your answer will be accepted if it has absolute or relative error at most $10^{-9}$ . More specifically, if your answer is $a$ and the jury answer is $b$ , your answer will be accepted if .
输入输出样例
输入 #1
3 200000 250000 250000 250000 250000
输出 #1
0.9000000000
Here, there is equal probability for the bag to contain 0,1,2,3 red balls. Also, it costs 0.2 to draw a ball from the bag.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted