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
- Account Balance — Easy
- Best Time to Buy and Sell Stock — Easy
- Count Above Average — Easy
- Dropped Frames — Easy
- Merge Two Sorted Arrays — Easy
- Restock Alert — Easy