Health Bar

Easy · rating 1000 · Arrays, Simulation

A character starts with start hit points and a maximum of max. The first line has start, max, and n. The second line has n deltas applied in order (positive heals, negative damage). HP is clamped to the range [0, max] after each. Print the final HP.

Constraints: 0 ≤ start ≤ max ≤ 109

Related problems

Open Health Bar in Code Arena →