← 返回 amazon 的题目列表Minimum Starting Health to Win with Armor Defense
类型:online_judge
amazon
Amazon Prime Games is designing a game. The player needs to pass n rounds to win the game. The rules of play are as follows:
The player loses power[i] health to complete round i.
The remaining health must be greater than or equal to 1.
The player can choose to use armor in some of the rounds. The armor will prevent damage of ⌊attack/2⌋.
Determine the minimum starting health for a player to win the game.
Example:
power = [1, 2, 6, 7] armor = 5
Function Description:
Complete the function minimumHealth(power, armor).
Parameters:
A list of integers power, where power[i] is the health loss required to pass round i.
An integer armor, representing the maximum armor defense power.
Returns: The minimum starting health needed to win the game.
Constraints:
1 ≤ len(power) ≤ 100000
1 ≤ power[i] ≤ 100000
Example
Input
1 2 6 7
5