310594: CF1857A. Array Coloring

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Array Coloringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given an array consisting of $n$ integers. Your task is to determine whether it is possible to color all its elements in two colors in such a way that the sums of the elements of both colors have the same parity and each color has at least one element colored.

For example, if the array is [$1,2,4,3,2,3,5,4$], we can color it as follows: [$\color{blue}{1},\color{blue}{2},\color{red}{4},\color{blue}{3},\color{red}{2},\color{red}{3},\color{red}{5},\color{red}{4}$], where the sum of the blue elements is $6$ and the sum of the red elements is $18$.

Input

The first line contains an integer $t$ ($1 \le t \le 1000$) — the number of test cases.

Each test case begins with a line containing an integer $n$ ($2 \le n \le 50$) — the length of the array $a$.

The next line contains $n$ integers $a_1,a_2, \dots, a_n$ ($1 \le a_i \le 50$) — the elements of the array $a$.

Output

For each test case, output "YES" (without quotes) if it is possible to color the array in two colors in such a way that the sums of the elements of both colors have the same parity and each color has at least one element colored, and "NO" otherwise.

You can output "Yes" and "No" in any case (for example, the strings "yES", "yes", and "Yes" will be recognized as correct answers).

ExampleInput
7
8
1 2 4 3 2 3 5 4
2
4 7
3
3 9 8
2
1 7
5
5 4 3 2 1
4
4 3 4 5
2
50 48
Output
YES
NO
YES
YES
NO
YES
YES
Note

The first sample is described in the statement.

In the second sample, there are only two colorings $[\color{blue}{4},\color{red}{7}]$ and $[\color{red}{4},\color{blue}{7}]$ , but in both cases the parity of sums is different.

In the third sample, you can color $[\color{blue}{3},\color{blue}{9},\color{red}{8}]$ and $12$ and $8$ are both even.

Output

题目大意:给定一个由n个整数组成的数组。任务是判断是否可以以两种颜色对数组元素进行着色,使得两种颜色的元素和具有相同的奇偶性,并且每种颜色都至少有一个着色元素。

输入数据格式:第一行包含一个整数t(1≤t≤1000)——测试用例的数量。每个测试用例以包含一个整数n(2≤n≤50)的行开始——数组a的长度。下一行包含n个整数a1,a2,…,an(1≤ai≤50)——数组a的元素。

输出数据格式:对于每个测试用例,如果可以以两种颜色对数组进行着色,使得两种颜色的元素和具有相同的奇偶性,并且每种颜色都至少有一个着色元素,则输出“YES”(不带引号),否则输出“NO”。输出可以是任何大小写形式的“Yes”和“No”。题目大意:给定一个由n个整数组成的数组。任务是判断是否可以以两种颜色对数组元素进行着色,使得两种颜色的元素和具有相同的奇偶性,并且每种颜色都至少有一个着色元素。 输入数据格式:第一行包含一个整数t(1≤t≤1000)——测试用例的数量。每个测试用例以包含一个整数n(2≤n≤50)的行开始——数组a的长度。下一行包含n个整数a1,a2,…,an(1≤ai≤50)——数组a的元素。 输出数据格式:对于每个测试用例,如果可以以两种颜色对数组进行着色,使得两种颜色的元素和具有相同的奇偶性,并且每种颜色都至少有一个着色元素,则输出“YES”(不带引号),否则输出“NO”。输出可以是任何大小写形式的“Yes”和“No”。

加入题单

上一题 下一题 算法标签: