QOJ.ac

QOJ

実行時間制限: 6 s メモリ制限: 1024 MB 満点: 22

#5913. Osmos

統計

Armin 正在玩一款由 Hemisphere Games 开发的物理益智游戏《Osmos》。在这款游戏中,他控制一个“微粒”(mote),通过移动来吸收更小的微粒。

“微粒”在英语中指小颗粒。在这款游戏中,它是一个可以吸收其他物体(或被其他物体吸收)的东西!本题中的游戏与《Osmos》理念相似,但并不要求你玩过该游戏。

当 Armin 的微粒吸收了一个更小的微粒时,他的微粒大小会增加该微粒的大小。变大之后,它可能能够吸收更多的微粒。例如:假设 Armin 的微粒大小为 10,其他微粒的大小分别为 9、13 和 19。起初,Armin 的微粒只能吸收大小为 9 的微粒。吸收后,它的大小变为 19。接着它只能吸收大小为 13 的微粒。吸收后,它的大小变为 32。现在 Armin 的微粒可以吸收最后一个微粒了。

注意,Armin 的微粒能够吸收另一个微粒的充要条件是该微粒的尺寸严格小于他的微粒。如果另一个微粒的大小与他的相同,他的微粒无法吸收它。

你需要负责编写程序来生成供 Armin 吸收的微粒。程序已经生成了一些不同大小的微粒,以及 Armin 的微粒。遗憾的是,给定他微粒的大小和其余微粒的列表,Armin 的微粒可能无法吸收所有微粒。

你想要解决这个问题。你可以按任意顺序、任意次数执行两种操作:添加一个任意正整数大小的微粒,或者移除现有的任意一个微粒。为了使 Armin 的微粒能够吸收所有其他微粒,最少需要执行多少次操作?

例如,假设 Armin 的微粒大小为 10,其他微粒的大小为 [9, 20, 25, 100]。当前游戏无法通关,但通过添加一个大小为 3 的微粒并移除大小为 100 的微粒,只需 2 次操作即可通关。此处的答案为 2。

样例

输入格式 1

4
2 2
2 1
2 4
2 1 1 6
10 4
25 20 9 100
1 4
1 1 1 1

输出格式 1

Case #1: 0
Case #2: 1
Case #3: 2
Case #4: 4

说明

尽管输入文件中微粒的大小有限制,但 Armin 的微粒在吸收其他微粒后可能会变得比给定的限制更大。

《Osmos》由 Hemisphere Games 开发。Hemisphere Games 不认可且未参与 Google Code Jam。

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.