#abc351a. A - The bottom of the ninth

A - The bottom of the ninth

Score: 100100 points

问题陈述

高桥队和青木队正在进行一场棒球比赛,高桥队首先击球。 目前,比赛已经进行到了第九局上半局,即将开始第九局下半局。

高桥队在第 ii 局上半局得分为 AiA_i1i91\leq i\leq 9),而青木队在第 jj 局下半局得分为 BjB_j1j81\leq j\leq 8)。 在第九局上半局结束时,高桥队的得分不低于青木队的得分。 确定青木队在第九局下半局需要得多少分才能赢得比赛。

在这里,如果比赛结束时双方打平,那么结果就是平局。因此,为了赢得比赛,青木队必须在第九局下半局结束时比高桥队多得至少一分。 高桥队在任何时刻的得分是到那时为止上半局得分的总和,而青木队的得分是到那时为止下半局得分的总和。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

Team Takahashi and Team Aoki are playing a baseball game, with Team Takahashi batting first.
Currently, the game has finished through the top of the ninth inning, and the bottom of the ninth is about to begin.

Team Takahashi scored AiA_i runs in the top of the ii-th inning (1i9)(1\leq i\leq 9), and Team Aoki scored BjB_j runs in the bottom of the jj-th inning (1j8)(1\leq j\leq 8).
At the end of the top of the ninth, Team Takahashi's score is not less than Team Aoki's score.
Determine the minimum number of runs Team Aoki needs to score in the bottom of the ninth to win the game.

Here, if the game is tied at the end of the bottom of the ninth, it results in a draw. Therefore, for Team Aoki to win, they must score strictly more runs than Team Takahashi by the end of the bottom of the ninth.
Team Takahashi's score at any point is the total runs scored in the tops of the innings up to that point, and Team Aoki's score is the total runs scored in the bottoms of the innings.

Constraints

  • 0Ai,Bj990\leq A_i, B_j\leq 99
  • $A_1 + A_2 + A_3 + A_4 + A_5 + A_6 + A_7 + A_8 + A_9 \geq B_1 + B_2 + B_3 + B_4 + B_5 + B_6 + B_7 + B_8$
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

A1A_1 A2A_2 A3A_3 A4A_4 A5A_5 A6A_6 A7A_7 A8A_8 A9A_9

B1B_1 B2B_2 B3B_3 B4B_4 B5B_5 B6B_6 B7B_7 B8B_8

Output

Print the minimum number of runs Team Aoki needs to score in the bottom of the ninth inning to win.

Sample Input 1

0 1 0 1 2 2 0 0 1
1 1 0 0 0 0 1 0

Sample Output 1

5

At the end of the top of the ninth inning, Team Takahashi has scored seven runs, and Team Aoki has scored three runs.
Therefore, if Team Aoki scores five runs in the bottom of the ninth, the scores will be 787-8, allowing them to win.
Note that scoring four runs would result in a draw and not a victory.

Sample Input 2

0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

Sample Output 2

1