#C7787. Minimum Rounds to Defeat Monsters
Minimum Rounds to Defeat Monsters
Minimum Rounds to Defeat Monsters
You are given a series of battles against monsters. In each battle, there are n monsters, each with an initial health value. In every round, every monster that is still alive (health > 0) takes damage d simultaneously. The goal is to determine the number of rounds required to defeat all monsters in the battle.
The number of rounds needed for a single monster with health hi is given by:
$$\text{Rounds}_i = \left\lceil \frac{h_i}{d} \right\rceil$$
The answer for each battle is the maximum over all monsters' rounds:
$$\text{Answer} = \max_{1 \le i \le n}\left\lceil \frac{h_i}{d} \right\rceil.$$
You need to process multiple battles.
inputFormat
The first line of input contains an integer T
representing the number of battles (test cases). For each battle:
- The first line contains two space-separated integers:
n
(number of monsters) andd
(damage dealt per round). - The second line contains
n
space-separated integers representing the initial health of each monster.
outputFormat
For each battle, output a single integer representing the minimum number of rounds required to defeat all monsters. Each result should be printed on a new line.
## sample3
4 10
40 20 30 50
2 15
30 45
3 7
8 14 21
5
3
3
</p>