#P11723. Maximizing Parity Sum

    ID: 13814 Type: Default 1000ms 256MiB

Maximizing Parity Sum

Maximizing Parity Sum

There are (N) cards numbered from 1 to (N), each having an integer (A_i) written on it.

You need to choose exactly (K) cards from these (N) cards. The score of a selection is computed as follows:
- If all the chosen cards have integers with the same parity (i.e., all odd or all even), the score is the sum of the chosen integers.
- Otherwise, the score is (0).

Determine the maximum score that can be obtained.

inputFormat

The first line contains two integers (N) and (K).
The second line contains (N) integers (A_1, A_2, \dots, A_N) separated by spaces.

outputFormat

Output a single integer representing the maximum score obtainable.

sample

5 3
1 2 3 4 5
9