CF2181J.Jinx or Jackpot

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

Jack is in his favourite casino and has 10001000 dollars. The casino has literally nothing but a single slot machine. Jack knows the history of this casino. Once upon a time, the future owner of the casino was walking and suddenly saw an array of nn integer choices p1,…,pnp_{1}, \dots, p_{n} each from 00 to 100100. He picked an index ii (1≤i≤n1 \leq i \leq n) uniformly at random and thought that it was a good idea to create a casino in which there is only one slot machine with jackpot probability of pi100\frac{p_i}{100}. And he created it.

Jack knows the array of choices p1,…,pnp_{1}, \dots, p_{n} that suddenly appeared to the owner during the walk, but he does not know which ii the owner picked. However, the chosen index ii is fixed forever; the slot machine always uses the same pip_i as explained below.

On the slot machine, Jack can bet xx dollars, where xx is a non-negative integer, and pull the lever. Then:

  1. With probability pi100\frac{p_i}{100} it will be a jackpot, and the slot machine returns 2x2x dollars to him, so he gains xx dollars.
  2. With probability 1−pi1001 - \frac{p_i}{100} it will be a jinx, and the slot machine returns nothing to him, so he loses xx dollars.

Even if Jack bets 00 dollars, he will understand whether it was a jinx or a jackpot.

Also, the slot machine is not very durable, so Jack can play at most kk rounds on it.

Find the maximum expected profit Jack can achieve by an optimal strategy. Here a profit is defined as the final amount of money Jack has minus his initial 10001000 dollars.

Of course, Jack can't make a bet that is more than his current balance.

杰克正在他最喜欢的赌场里,身上有 1000 美元。这家赌场里只有一台老虎机。杰克了解这家赌场的历史:很久以前,这家赌场未来的老板在路上散步时,突然看到了一个由 nn 个整数 p1,…,pnp_{1}, \dots, p_{n} 组成的数组,其中每个 pjp_j 均在 00 到 100100 之间(含端点)。他从 11 到 nn 中均匀随机地选取了一个下标 ii(即 1≤i≤n1 \leq i \leq n),并认为以 pi100\frac{p_i}{100} 为中奖概率设置一台老虎机是个不错的主意——于是他就照此建起了这家赌场。

杰克知道老板散步时偶然看到的那个数组 p1,…,pnp_{1}, \dots, p_{n},但他并不知道老板当时究竟选中了哪一个下标 ii。然而,这个被选中的下标 ii 是永久固定的;如前所述,这台老虎机始终使用同一个 pip_i。

在该老虎机上,杰克每次可以下注 xx 美元,其中 xx 是一个非负整数,然后拉动拉杆。此时:

  1. 以概率 pi100\frac{p_i}{100} 触发“头奖”(jackpot),老虎机返还 2x2x 美元,因此杰克净赚 xx 美元;
  2. 以概率 1−pi1001 - \frac{p_i}{100} 触发“厄运”(jinx),老虎机不返还任何钱,因此杰克净亏 xx 美元。

即使杰克下注 00 美元,他仍能获知本次结果是“厄运”还是“头奖”。

此外,这台老虎机不够耐用,杰克最多只能玩 kk 轮。

请计算杰克通过最优策略所能获得的最大期望收益。此处“收益”定义为:杰克最终拥有的钱数减去其初始资金 10001000 美元。

当然,杰克不能下注超过其当前余额的金额。

输入格式

The first line contains two integers nn and kk (1≤n≤100 0001 \leq n \leq 100\,000; 1≤k≤301 \leq k \leq 30) — the number of choices and the limit on the number of rounds. The second line contains nn integers p1,…,pnp_{1}, \dots, p_{n} (0≤pi≤1000 \le p_i \le 100) — the choices.

第一行包含两个整数 nn 和 kk(1≤n≤100 0001 \leq n \leq 100\,000;1≤k≤301 \leq k \leq 30)—— 分别表示选项数量和轮次上限。
第二行包含 nn 个整数 p1,…,pnp_{1}, \dots, p_{n}(0≤pi≤1000 \le p_i \le 100)—— 表示各个选项。

输出格式

Output a single real number — the expected profit Jack can achieve by an optimal strategy. Your answer will be considered correct if its absolute or relative error is at most 10−410^{-4}.

输出一个实数——Jack 通过最优策略所能获得的期望收益。若你的答案的绝对误差或相对误差不超过 10−410^{-4},则视为正确。

输入输出样例

  • 输入#1

    2 2
    70 30

    输出#1

    160
  • 输入#2

    2 30
    30 70

    输出#2

    12099716.1778528057038784
  • 输入#3

    2 5
    40 50

    输出#3

    0
  • 输入#4

    6 6
    10 20 60 30 40 50

    输出#4

    29.40799999999990177457221
  • 输入#5

    1 5
    61

    输出#5

    1702.708163199999489734182

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

首页