#K70102. Even Sum Pair Problem
Even Sum Pair Problem
Even Sum Pair Problem
You are given an array of n integers. Your task is to determine whether there exists a pair of distinct indices \(i\) and \(j\) (with \(1 \le i < j \le n\)) such that the sum of the corresponding elements is an even number under the following rule:
A pair is considered valid if and only if either:
- There are at least two even numbers in the array, or
- There is at least one even number and at least one odd number in the array.
Notice that a pair formed by two odd numbers does not count, even though mathematically the sum of two odd numbers is even. This is a twist in the problem definition.
The condition can be formally written in LaTeX as:
$$\text{Answer} = \begin{cases}\text{YES}, & \text{if } (\text{even} \geq 2) \lor (\text{even} \geq 1 \ \wedge\ \text{odd} \geq 1) \\ \text{NO}, & \text{otherwise.}\end{cases}$$
inputFormat
The input is read from standard input (stdin) and has the following format:
T n a1 a2 ... an ...
Here, the first line contains a single integer \(T\) denoting the number of test cases. For each test case, the first line contains an integer \(n\) (the size of the array), and the second line contains \(n\) space-separated integers representing the array elements.
outputFormat
For each test case, output a single line to standard output (stdout) containing either YES
if a valid pair exists, or NO
otherwise.
1
3
1 3 5
NO
</p>