CF1857A.Array Coloring
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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: [1,2,4,3,2,3,5,4], where the sum of the blue elements is 6 and the sum of the red elements is 18.
给你一个包含 n 个整数的数组。你的任务是判断:能否将数组中所有元素染成两种颜色,使得两种颜色各自对应元素的和具有相同的奇偶性,且每种颜色至少染有一个元素。
例如,对于数组 [1,2,4,3,2,3,5,4],可以按如下方式染色:[1,2,4,3,2,3,5,4],其中蓝色元素之和为 6,红色元素之和为 18。
输入格式
The first line contains an integer t (1≤t≤1000) — the number of test cases.
Each test case begins with a line containing an integer n (2≤n≤50) — the length of the array a.
The next line contains n integers a1,a2,…,an (1≤ai≤50) — the elements of the array a.
第一行包含一个整数 t(1≤t≤1000)—— 测试用例的数量。
每个测试用例以一行开始,该行包含一个整数 n(2≤n≤50)—— 数组 a 的长度。
下一行包含 n 个整数 a1,a2,…,an(1≤ai≤50)—— 数组 a 的元素。
输出格式
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).
对于每个测试用例,如果可以将数组中的元素染成两种颜色,使得两种颜色对应元素的和具有相同的奇偶性,且每种颜色至少染有一个元素,则输出 "YES"(不带引号);否则输出 "NO"。
你可以以任意大小写形式输出 "Yes" 和 "No"(例如,字符串 "yES"、"yes" 和 "Yes" 均会被判为正确答案)。
输入输出样例
输入#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] and [4,7] , but in both cases the parity of sums is different.
In the third sample, you can color [3,9,8] and 12 and 8 are both even.
第一个样例在题目描述中已给出。
在第二个样例中,仅有两种染色方案:[4,7] 和 [4,7],但在这两种情况下,两组数的和的奇偶性均不同。
在第三个样例中,你可以将数组染色为 [3,9,8],此时蓝色数字之和 12 与红色数字之和 8 均为偶数。
输入解题思路,AI测评打分。不知道怎么写?