CF1890A.Doremy's Paint 3
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An array b1,b2,…,bn of positive integers is good if all the sums of two adjacent elements are equal to the same value. More formally, the array is good if there exists a k such that b1+b2=b2+b3=…=bn−1+bn=k.
Doremy has an array a of length n. Now Doremy can permute its elements (change their order) however she wants. Determine if she can make the array good.
一个由正整数构成的数组 b1,b2,…,bn 被称为“好”的,当且仅当其所有相邻两元素之和均相等。更准确地说,若存在某个 k,使得
b1+b2=b2+b3=…=bn−1+bn=k,
则该数组是“好”的。
Doremy 有一个长度为 n 的数组 a。现在 Doremy 可以任意重排(即改变顺序)其元素。请判断她能否将该数组重排成一个“好”的数组。
输入格式
The input consists of multiple test cases. The first line contains a single integer t (1≤t≤100) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer n (2≤n≤100) — the length of the array a.
The second line of each test case contains $ n $ integers $ a_1,a_2,\ldots,a_n $ (1≤ai≤105).
There are no constraints on the sum of n over all test cases.
输入包含多个测试用例。第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(2≤n≤100),表示数组 a 的长度。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤105)。
对所有测试用例的 n 值之和不作限制。
输出格式
For each test case, print "Yes" (without quotes), if it is possible to make the array good, and "No" (without quotes) otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
对于每个测试用例,如果可以将该数组变为“好”的数组,则输出“Yes”(不带引号);否则输出“No”(不带引号)。
你可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被识别为肯定回答。
输入输出样例
输入#1
5 2 8 9 3 1 1 2 4 1 1 4 5 5 2 3 3 3 3 4 100000 100000 100000 100000
输出#1
Yes Yes No No Yes
说明/提示
In the first test case, [8,9] and [9,8] are good.
In the second test case, [1,2,1] is good because a1+a2=a2+a3=3.
In the third test case, it can be shown that no permutation is good.
在第一个测试用例中,[8,9] 和 [9,8] 是“好”的。
在第二个测试用例中,[1,2,1] 是“好”的,因为 a1+a2=a2+a3=3。
在第三个测试用例中,可以证明不存在“好”的排列。
输入解题思路,AI测评打分。不知道怎么写?