CF838F.Expected Earnings

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 / 106 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.

你正在玩一个装有红球和黑球的袋子的游戏。初始时,你知道袋中总共有 nn 个球。此外,你还被告知:袋中恰好含有 ii 个红球的概率为 pi/106p_i / 10^6。

现在你想从这个袋子中购买球。你特别喜欢红色,因此每个红球价值为 11 单位,而黑球毫无价值。要购买一个球,只要袋中仍有球,你就需支付成本 cc(其中 0≤c≤10 \leq c \leq 1),然后从袋中随机抽取一个球。你可以在任意时刻选择停止购买(甚至可以选择完全不购买任何球)。

假设你以最大化期望收益(即:获得的红球数量 −- 购买它们所需的成本)的方式进行最优购买,请输出最大期望收益。

输入格式

The first line of input will contain two integers n, X (1 ≤ n ≤ 10 000, 0 ≤ X ≤ 106).

The next line of input will contain n + 1 integers _p_0, _p_1, ... p__n (0 ≤ p__i ≤ 106, )

The value of c can be computed as .

输入的第一行包含两个整数 nn 和 XX(1≤n≤10 0001 \leq n \leq 10\,000,0≤X≤1060 \leq X \leq 10^6)。

输入的第二行包含 n+1n+1 个整数 p0, p1, …, pnp_0,\,p_1,\,\dots,\,p_n(0≤pi≤1060 \leq p_i \leq 10^6,)

值 cc 可通过公式 计算得到。

输出格式

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 .

输出一个浮点数,表示最优的期望值。

若你的答案的绝对误差或相对误差不超过 10−910^{-9},则视为正确。更具体地说,若你的答案为 aa,评测机的标准答案为 bb,则当满足 时,你的答案将被接受。

输入输出样例

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

此处,袋子中包含 0、1、2、3 个红球的概率均等。此外,从袋子中抽取一个球的代价为 0.2。

输入解题思路,AI测评打分。不知道怎么写?

首页