CF1857A.Array Coloring

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array consisting of nn 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,41,2,4,3,2,3,5,4 ], we can color it as follows: [ 1,2,4,3,2,3,5,4\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 66 and the sum of the red elements is 1818 .

输入格式

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

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

The next line contains nn integers a1,a2,,ana_1,a_2, \dots, a_n ( 1ai501 \le a_i \le 50 ) — the elements of the array aa .

输出格式

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).

输入输出样例

  • 输入#1

    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

    输出#1

    YES
    NO
    YES
    YES
    NO
    YES
    YES

说明/提示

The first sample is described in the statement.

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

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

首页