QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#2753. 捡骰子

統計

两名玩家正在使用 $K$ 枚六面骰子进行游戏。一名玩家喊出一个 $K \dots 6K$ 范围内的数字,另一名玩家尝试掷出该数字。在第一次投掷后,玩家可以选择拾起任意数量($0 \dots K$)的骰子并重新投掷。

给定骰子的数量、玩家想要掷出的目标数字,以及玩家在第一次投掷中得到的数字集合,玩家应该拾起多少枚骰子进行重掷,才能使第二次投掷后总和达到目标数字的概率最大化?

输入格式

输入的第一行包含两个整数 $K$(骰子数量)和 $T$(目标数字)。$2 \le K \le 24$,$K \le T \le 6K$。

下一行包含 $K$ 个整数,表示第一次投掷中每枚骰子的点数。所有数字均为 $1 \dots 6$ 范围内的整数。

输出格式

输出一行,包含一个整数,表示为了使总和达到 $T$ 的概率最大化,玩家应该拾起并重掷的骰子数量。(玩家可以选择拾起哪些骰子,但你只需要输出骰子的数量,无需输出具体是哪几枚。)

如果存在多个可拾起的骰子数量能达到相同的概率,请输出其中最小的一个。

样例

样例输入 1

3 9
5 4 1

样例输出 1

1

样例输入 2

4 13
2 2 2 2

样例输出 2

3

样例输入 3

18 90
1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6

样例输出 3

12

样例输入 4

6 21
1 2 3 4 5 6

样例输出 4

0

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.