#K61872. Cumulative Score Winner
Cumulative Score Winner
Cumulative Score Winner
In this problem, you are given scores of two players, A and B, over N rounds. Each player obtains a certain score in each round. Your task is to determine the winner by comparing the cumulative scores of both players. Specifically, let the cumulative scores be defined as:
\( S_A = \sum_{i=1}^{N} A_i \) and \( S_B = \sum_{i=1}^{N} B_i \).
If \( S_A > S_B \), then player A wins and the output should be \( S_A \). If \( S_B > S_A \), then player B wins and the output should be \( S_B \). Otherwise, if \( S_A = S_B \), print -1 to indicate a tie.
Input and Output: The input is read from stdin
and the result should be printed to stdout
.
inputFormat
The input consists of three lines:
- The first line contains an integer N representing the number of rounds.
- The second line contains N space-separated integers representing the scores of player A.
- The third line contains N space-separated integers representing the scores of player B.
outputFormat
Output a single integer which is the total score of the winning player if one exists. If both players have the same cumulative score, output -1.
## sample3
10 20 30
30 20 10
-1