#C4466. Odd Subset Sum Possibility
Odd Subset Sum Possibility
Odd Subset Sum Possibility
You are given an integer n and a list of n integers. Your task is to determine whether there exists a non-empty subset of the given integers such that the sum of the subset is odd.
A subset's sum is odd if and only if
\[
\sum_{i \in S} a_i \equiv 1 \pmod{2}
\]
for some non-empty subset S
of the indices. Note that selecting a single odd element is sufficient to achieve an odd sum.
Print YES
if such a subset exists, and NO
otherwise.
inputFormat
The input is given from stdin as follows:
- The first line contains a single integer
n
(1 ≤ n ≤ 105), the number of elements. - The second line contains
n
space-separated integersa1, a2, ..., an
(−109 ≤ ai ≤ 109).
outputFormat
Output to stdout a single line containing YES
if it is possible to choose a non-empty subset whose sum is odd, or NO
otherwise.
3
2 4 6
NO
</p>