#abc339c. C - Perfect Bus
C - Perfect Bus
Score: points
问题描述
一辆公交车正在运行。车上的乘客人数始终是非负整数。
在某一时刻,公交车上可能有零个或多个乘客,并且从那时起已经停靠了 次。在第 次停车时,乘客人数增加了 。这里, 可以为负数,意味着乘客人数减少了 。此外,除了在这些停车点外,没有乘客上下车。
请找出与给定信息相一致的、当前公交车上乘客数目的最小可能值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
A bus is in operation. The number of passengers on the bus is always a non-negative integer.
At some point in time, the bus had zero or more passengers, and it has stopped times since then. At the -th stop, the number of passengers increased by . Here, can be negative, meaning the number of passengers decreased by . Also, no passengers got on or off the bus other than at the stops.
Find the minimum possible current number of passengers on the bus that is consistent with the given information.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
3 -5 7 -4
Sample Output 1
3
If the initial number of passengers was , the current number of passengers would be , and the number of passengers on the bus would have always been a non-negative integer.
Sample Input 2
5
0 0 0 0 0
Sample Output 2
0
Sample Input 3
4
-1 1000000000 1000000000 1000000000
Sample Output 3
3000000000
update @ 2024/3/10 01:31:08