QOJ.ac

QOJ

时间限制: 3 s 内存限制: 2048 MB 总分: 100

#2197. 游戏遗物

统计

电子竞技是一种使用电子游戏的竞技运动。Dota 2 是电子竞技中最受欢迎的竞技游戏之一。最近,一款名为 Dota 3 的新游戏发布了。在 Dota 3 中,玩家可以为他们的英雄购买一些遗物(relics)。遗物是记录英雄在游戏中的动作和统计数据的计数器。

Gloria 喜欢玩 Dota 3,所以她想为她最喜欢的英雄买齐所有 $n$ 个可用的遗物。

遗物可以使用一种名为“碎片”(shards)的游戏内货币购买。每个遗物都有自己的价格——第 $i$ 个遗物的价格为 $c_i$ 个碎片。玩家可以通过以下两种方式之一购买遗物:

  • 支付 $c_i$ 个碎片购买第 $i$ 个遗物;
  • 支付 $x$ 个碎片随机获得所有 $n$ 个遗物中的一个。获得每个遗物的概率相同。如果收到了重复的遗物,则该遗物会被回收,并返还给玩家 $\frac{x}{2}$ 个碎片。

Gloria 想要买齐所有 $n$ 个遗物。请帮助她最小化购买所有遗物所需花费的碎片期望值。

输入格式

第一行包含两个整数 $n$ 和 $x$ ($1 \le n \le 100; 1 \le x \le 10\,000$),分别表示遗物的数量和随机获取一个遗物的成本。

第二行包含 $n$ 个整数 $c_1, c_2, \dots, c_n$ ($x \le c_i \le 10\,000; \sum c_i \le 10\,000$),表示 $n$ 个遗物的价格。

输出格式

输出一个实数,表示 Gloria 买齐所有遗物所需花费的最小碎片期望值。

输出的绝对误差或相对误差不应超过 $10^{-9}$。

样例

样例输入 1

2 20
25 100

样例输出 1

47.50000000000000000

样例输入 2

4 30
60 50 60 80

样例输出 2

171.25000000000000000

说明

在第一个样例中,最优策略是支付 20 个碎片随机获取两个遗物中的一个。之后有两种情况。

第一种情况是 Gloria 收到了第一个遗物。然后她继续随机获取遗物,直到获得第二个遗物。在这种情况下,花费的碎片期望值为 $20 + 30 = 50$。

在第二种情况中,Gloria 最初获得了第二个遗物。此时,以 25 个碎片直接购买第一个遗物会更好,因此在这种情况下,花费的碎片期望值为 $20 + 25 = 45$。

因此,花费的碎片期望值为 $\frac{50+45}{2} = 47.5$。

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 1
IDTypeStatusTitlePosted ByLast UpdatedActions
#430General DiscussionOpenHow to construct solution for the following TC?RDFZchenyy2025-12-18 23:06:21View

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.