MathWorksOA #19
Discount Tags
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyBits & Math
From tag values that may be positive or negative, choose any number of them (possibly none) so that the sum is even; find the maximum possible even sum. The source guarantees at least one even number.
This site uses a standard input/output protocol.
Input
The first line contains n; the second line contains n integers. Constraints added by this site: 1≤n≤100000, |val[i]|≤10^9.
Output
Output the maximum even sum.
Example 1
Input:
4
3 2 5 -1
Output:
10
Example 2
Input:
3
4 -2 3
Output:
4
Example 3
Input:
1
0
Output:
0
Example 4
Input:
2
2 -5
Output:
2
Editorial
Loading solution…