QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#15902. 厄运还是大奖

الإحصائيات

Jack 在他最喜欢的赌场里,手头有 1000 美元。这家赌场除了一台老虎机外,什么都没有。Jack 知道这家赌场的历史。很久以前,赌场未来的老板在散步时,突然看到了一个由 $n$ 个整数选项组成的数组 $p_1, \dots, p_n$,每个数都在 0 到 100 之间。他等概率随机选择了一个下标 $i$ ($1 \le i \le n$),并认为建立一个只有一台老虎机、且中奖(jackpot)概率为 $\frac{p_i}{100}$ 的赌场是个好主意。于是他创建了这家赌场。

Jack 知道老板散步时突然看到的选项数组 $p_1, \dots, p_n$,但他不知道老板具体选了哪一个 $i$。然而,选定的下标 $i$ 是永远固定不变的;老虎机总是使用同一个 $p_i$,具体规则如下。

在老虎机上,Jack 可以下注 $x$ 美元(其中 $x$ 是一个非负整数),然后拉动拉杆。接着:

  1. 有 $\frac{p_i}{100}$ 的概率会中奖(jackpot),老虎机将返还给他 $2x$ 美元,因此他净赚 $x$ 美元。
  2. 有 $1 - \frac{p_i}{100}$ 的概率会走霉运(jinx),老虎机什么都不返还,因此他损失 $x$ 美元。

即使 Jack 下注 0 美元,他也能知道结果是走霉运还是中奖。

此外,这台老虎机不是很耐用,所以 Jack 最多只能在上面玩 $k$ 轮。

求 Jack 采用最优策略所能获得的最大的期望利润。这里的利润定义为 Jack 最终拥有的资金减去他初始的 1000 美元。

当然,Jack 的下注额不能超过他当前的余额。

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le n \le 100\,000$;$1 \le k \le 30$) —— 选项的数量和最大轮数限制。

第二行包含 $n$ 个整数 $p_1, \dots, p_n$ ($0 \le p_i \le 100$) —— 选项。

输出格式

输出一个实数 —— Jack 采用最优策略所能获得的期望利润。如果你的答案的绝对或相对误差不超过 $10^{-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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.