cswork / OA打开练习工作台

IBMOA #23

Find Maximum Even Sum

估计中等可在线判题

考点(AI 标注)贪心调度位运算

Choose any number of items from an integer array so that their sum is even and as large as possible; choosing no items is allowed. There is at least one even element, and elements may be negative.

输入格式

The first line contains n, and the second line contains the array. On this site 1≤n≤200000, −10^9≤element≤10^9, and there is at least one even number.

输出格式

Output one integer, the answer.

样例 1

输入:

7
2 3 6 -5 10 1 1

输出:

22

样例 2

输入:

2
-2 -3

输出:

0

样例 3

输入:

3
1 1 2

输出:

4

样例说明

The examples give 22, 0 and 4 respectively; negative numbers do not have to be chosen.