#C9573. Maximum Even Sum
Maximum Even Sum
Maximum Even Sum
Alice and Bob are playing a strategic game with an array of integers. In this game, the players take turns choosing a number from the array. Alice loves even numbers and will only pick an even number when available, while Bob will always choose an odd number when possible. Both players play optimally.
The task is to determine the total sum of the even numbers that Alice collects during the game. In other words, given a list of integers \(a_1, a_2, \dots, a_n\), let \(E = \{a_i \mid a_i \text{ is even}\}\); you are required to compute \[ S = \sum_{x \in E} x, \] and output \(S\). If no even numbers are chosen, output 0.
inputFormat
The first line contains a single integer \(n\) (\(1 \le n \le 10^5\)), the number of elements in the array.
The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\) (\(1 \le a_i \le 10^9\)).
outputFormat
Output a single integer, the sum of the even numbers selected by Alice.
## sample6
10 5 3 2 8 7
20