cswork / OA打开练习工作台

MathWorksOA #17

Maximum Even Sum Subsequence

估计中等评测数据准备中,可先阅读题面

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

Given a array of n positive and negative integers, find the subsequence with the maximum even sum and display that even sum.

Constraints

N/A

Example 1

Input:

arr = [-2, 2, -3, 1, 3]

Output:

6

Explanation: The longest subsequence with even sum is 2, 1 and 3.

Example 2

Input:

arr = [-2, 2, -3, 4, 5]

Output:

8

Explanation: The longest subsequence with even sum is 2, -3, 4 and 5.