103510: [Atcoder]ABC351 A - The bottom of the ninth

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:5 Solved:0

Description

Score: $100$ points

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 $A_i$ runs in the top of the $i$-th inning $(1\leq i\leq 9)$, and Team Aoki scored $B_j$ runs in the bottom of the $j$-th inning $(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

  • $0\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:

$A_1$ $A_2$ $A_3$ $A_4$ $A_5$ $A_6$ $A_7$ $A_8$ $A_9$
$B_1$ $B_2$ $B_3$ $B_4$ $B_5$ $B_6$ $B_7$ $B_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 $7-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

Output

得分:100分

题目描述

Takahashi 队和 Aoki 队正在进行一场棒球比赛,Takahashi 队先击球。
目前,比赛已经进行到了第九局上半局结束,第九局下半局即将开始。

Takahashi 队在第 $i$ 局上半局得分 $A_i$ ($1\leq i\leq 9$),而 Aoki 队在第 $j$ 局下半局得分 $B_j$ ($1\leq j\leq 8$).
在第九局上半局结束时,Takahashi 队的得分不低于 Aoki 队的得分。
确定 Aoki 队在第九局下半局需要得到的最少分数以赢得比赛。

在这里,如果在第九局下半局结束时比赛打平,则比赛结果为平局。因此,为了赢得比赛,Aoki 队必须在第九局下半局结束时得分严格高于 Takahashi 队。
Takahashi 队在任何时刻的得分是前半局得分之和,而 Aoki 队的得分是下半局得分之和。

约束条件

  • $0\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$
  • 所有输入值均为整数。

输入

输入数据从标准输入以如下格式给出:

$A_1$ $A_2$ $A_3$ $A_4$ $A_5$ $A_6$ $A_7$ $A_8$ $A_9$
$B_1$ $B_2$ $B_3$ $B_4$ $B_5$ $B_6$ $B_7$ $B_8$

输出

输出 Aoki 队在第九局下半局需要得到的最少分数以赢得比赛。


样例输入 1

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

样例输出 1

5

在第九局上半局结束时,Takahashi 队共得七分,而 Aoki 队共得三分。
因此,如果 Aoki 队在第九局下半局得到五分,比分将变为 $7-8$,这样他们就能获胜。
需要注意的是,得到四分只会造成平局,而非胜利。


样例输入 2

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

样例输出 2

1

Sample Input Copy


Sample Output Copy


加入题单

算法标签: