Battery Reset Counter
EasyA rechargeable battery starts empty (charge = 0). You process n signed events in order; event e adds e to the current charge, and e may be negative. The battery can never hold a negative charge: the instant the charge would drop below 0 it is clamped back to exactly 0, and that clamp counts as one reset.
Formally, start with charge = 0 and resets = 0. For each event e in order, set charge = charge + e; then if charge < 0, set charge = 0 and add 1 to resets.
Input format:
- First line: n
- Second line: n integers (the events)
Print two integers separated by a single space: the final charge and the number of resets. The final charge can exceed a 32-bit integer, so use 64-bit arithmetic.
Constraints
1 <= n <= 10^5 -10^9 <= e <= 10^9