#K71162. Cumulative Time Travel Year Calculation
Cumulative Time Travel Year Calculation
Cumulative Time Travel Year Calculation
In this problem, you are given a list of integer fuel units that represent the energy provided for time travel at each step. Starting from year 0, Dr. Brown accumulates fuel to travel through time. However, if at any point the cumulative fuel becomes negative, it is reset to 0.
Your task is to compute the final cumulative year after processing all fuel units. The calculation follows the rule:
\(year_i = \max(0, year_{i-1} + fuel_i)\)
For example, given the sequence [10, -5, 20, -25], the cumulative calculation would be: 10, 5, 25, 0, resulting in a final output of 0.
inputFormat
The first line of input contains an integer n representing the number of fuel units. The second line contains n space-separated integers, each representing a fuel unit.
Constraints: 0 ≤ n ≤ 100000; Each fuel unit is an integer.
outputFormat
Output a single integer, which is the cumulative year Dr. Brown can travel to after processing all fuel units.
## sample3
10 20 30
60