304386: CF838F. Expected Earnings

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Expected Earnings

题意翻译

袋子里有$n$个球,球有两种:红球和黑球。袋子中刚好有$k$个红球的概率为$\frac{p_k}{10^6}$,$p$满足条件$(\sum\limits_{j=0}^np_j=10^6)$ 每次你珂以从袋子中随机掏出一个球,花费为$\frac{X}{10^6}$。你每掏出一个红球都会得到$1$的收益,掏出黑球没有收益。你珂以随时停止掏球(甚至不掏球)。 求以最优方案操作时获得的最大期望收益。

题目描述

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.

输入输出格式

输入格式


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} $ , ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF838F/7db6b8342276851a78020e225114985f8bcff7e6.png)) The value of $ c $ can be computed as ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF838F/6efe404963af6b3d99ee39cb1c0a64c063c32bf4.png).

输出格式


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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF838F/d8d110e69d298146d951837cc2710d1c4cc74a7d.png).

输入输出样例

输入样例 #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.

Input

题意翻译

袋子里有$n$个球,球有两种:红球和黑球。袋子中刚好有$k$个红球的概率为$\frac{p_k}{10^6}$,$p$满足条件$(\sum\limits_{j=0}^np_j=10^6)$ 每次你珂以从袋子中随机掏出一个球,花费为$\frac{X}{10^6}$。你每掏出一个红球都会得到$1$的收益,掏出黑球没有收益。你珂以随时停止掏球(甚至不掏球)。 求以最优方案操作时获得的最大期望收益。

加入题单

算法标签: