QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#9717. 拆除炸弹

Estadísticas

恐怖分子在大楼里安放了一些炸弹!我们的英雄 Little Horse 决定去营救大楼里的人。不幸的是,炸弹不止一个,Little Horse 无法拆除所有炸弹。为了给其他人争取更多的逃生时间,Little Horse 决定牺牲自己。

大楼里有 $n$ 个炸弹,每个炸弹都有一个倒计时时钟。起初,第 $i$ 个炸弹的时钟被设置为 $a_i$。随后进行以下步骤:

  1. Little Horse 选择一个炸弹,使其时钟增加 1。
  2. 每个炸弹的时钟减少 1。
  3. 如果至少有一个时钟变得小于 0,所有炸弹都会爆炸。否则,回到第 1 步。

显然,爆炸是不可避免的。这是一个悲伤的故事。但 Little Horse 现在并不关心自己的生死。他只想争取更多的时间。那么,你能告诉他在爆炸前他最多能执行多少次第 1 步吗?

输入格式

输入的第一行包含一个整数 $T$ ($1 \le T \le 100$),表示测试用例的数量。

每个测试用例的第一行包含一个整数 $n$ ($2 \le n \le 10^5$),表示炸弹的数量。所有测试用例的 $n$ 之和不超过 $3 \times 10^5$。

下一行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \le a_1, a_2, \dots, a_n \le 10^9$),表示炸弹初始的时钟数值。

输出格式

对于第 $x$ 个测试用例,如果答案为 $y$,请在一行中输出 Case #x: y

样例

输入 1

2
2
1 1
3
1 2 3

输出 1

Case #1: 3
Case #2: 4

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.