#K461. Calculate Total Score
Calculate Total Score
Calculate Total Score
You are given two arrays A and B each of length N. Your task is to compute the total score using the following rule:
For each index \( i \) (where \( 0 \leq i < N \)):
- If \( B_i \) is even, add \( A_i \) to the total score.
- If \( B_i \) is odd, add \( B_i \) to the total score.
The final answer is the sum of all contributions. In mathematical terms, the total score \( S \) is given by:
\[ S = \sum_{i=0}^{N-1}\begin{cases} A_i, & \text{if } B_i \equiv 0 \; (\mathrm{mod}\;2)\\ B_i, & \text{if } B_i \equiv 1 \; (\mathrm{mod}\;2) \end{cases} \]Print the final total score.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains a single integer N, which is the number of elements in the arrays.
- The second line contains N space-separated integers representing the elements of array A.
- The third line contains N space-separated integers representing the elements of array B.
For example:
5 1 2 3 4 5 6 7 8 9 10
outputFormat
Output a single integer representing the total score computed according to the given rules. The result should be written to standard output (stdout).## sample
5
1 2 3 4 5
6 7 8 9 10
25