A rain tank starts empty and can hold at most capacity litres. Each day the amount in inflows pours in. Whatever does not fit spills over the top and is lost. Write total_spilled(capacity, inflows) that returns the total number of litres spilled over all days.
Examples
Input: capacity = 10, inflows = [4, 5, 6, 2]
Output: 7
Explanation: level 4, then 9, then 15 -> spill 5 and stay at 10, then 12 -> spill 2. Total 7.
Input: capacity = 5, inflows = [1, 1]
Output: 0
Constraints
0 <= capacity <= 10**60 <= len(inflows) <= 10**50 <= inflows[i] <= 1000
Goals
- Simulate a container with a capacity limit day by day
- Track two running quantities (level and spilled total) at once