Official
A - The bottom of the ninth Editorial by en_translator
Suppose that team Takahashi’s score at the end of the top of the ninth is \(X\), and team Aoki’s is \(Y\). (By the constraints of the problem, \(X>Y\).)
Here, \(X\) and \(Y\) can be found as \(X=A_1+A_2+\cdots+A_9\) and \(Y=B_1+B_2+\cdots+B_8\), respectively.
Here, if the runs of team Aoki in the bottom of the ninth is less than or equal to \((X-Y-1)\), team Takahashi wins; if it is \((X-Y)\), the game draw; if it is greater than or equal to \((X-Y+1)\), team Aoki wins.
Therefore, the minimum runs required for team Aoki to win is \((X-Y+1\), which should be printed.
Sample code in C++:
#include <bits/stdc++.h>
using namespace std;
int main() {
int a=0,b=0,x;
for(int i=0;i<9;i++){
cin>>x;
a+=x;
}
for(int j=0;j<8;j++){
cin>>x;
b+=x;
}
cout<<(a-b+1)<<endl;
return 0;
}
Sample code in Python:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(sum(A)-sum(B)+1)
posted:
last update: