#K92447. Rounds to All Death
Rounds to All Death
Rounds to All Death
You are given M magical creatures. Each creature has a certain number of hit points (HP). In every round, every creature that is still alive (i.e. with HP > 0) will have its hit points reduced to the floor of its half, i.e. its hit points are updated as
$$HP \leftarrow \lfloor \frac{HP}{2} \rfloor$$
This process is repeated until every creature has 0 hit points. Your task is to determine the number of rounds required for all creatures to die.
Example: For M = 4 and HP = [10, 9, 16, 7], after 5 rounds all creatures will have 0 hit points.
inputFormat
The input consists of two lines:
- The first line contains a single integer M (1 ≤ M ≤ 105) denoting the number of creatures.
- The second line contains M space-separated integers, where each integer represents the hit points (0 ≤ HP ≤ 109) of a creature.
outputFormat
Print a single integer: the number of rounds needed until all creatures’ hit points become 0.
## sample4
10 9 16 7
5
</p>