Bottom up aproach works and no edge cases


I just wanted to say that a DP solution exists, that involves a bottom up aproach and with one simple rule there are no edge cases.

You just have to think in reverse, negative powerup is a positive HP requirement, and viceversa. Also remember you always need a minim of 1 HP left, and to cut down the excess.