#5070. The bottom of the ninth

0
    ID: 5070 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>AtCoderabc351AGESP 1级枚举(单层循环)模拟

The bottom of the ninth

The bottom of the ninth

题目描述

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 (1≤i≤9)(1\leq i\leq 9), and Team Aoki scored BjB_j runs in the bottom of the jj-th inning (1≤j≤8)(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.

输入格式

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

输出格式

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

0 1 0 1 2 2 0 0 1
1 1 0 0 0 0 1 0
5
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1

提示

0≤Ai,Bj≤990\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.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−87-8, allowing them to win.
Note that scoring four runs would result in a draw and not a victory.

标签: AtCoder|abc351A

来源

AtCoder|abc351A