cswork / OA打开练习工作台

UberOA #22

Character Health in a Video Game

估计简单可在线判题

考点(AI 标注)模拟/实现

The initial health is between 0 and 100. Add each change in order, clamping the result to [0,100] after every step, and output the final value.

This site's standard input/output is stated explicitly.

输入格式

The first line contains n initial, and the second line contains n changes. On this site n is 0..100000, initial is 0..100, and changes are −10⁹..10⁹.

输出格式

Output one integer answer.

样例 1

输入:

4 12
-4 -12 6 2

输出:

8

样例 2

输入:

2 95
20 -10

输出:

90

样例 3

输入:

0 10

输出:

10

样例说明

Example 1: the health goes 8, 0, 6, 8, so the output is 8. Example 2: it first reaches the cap of 100 and then loses 10, so the output is 90. Example 3: with no changes, it stays at 10.