CF1686A.Everything Everywhere All But One

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an array of nn integers a1,a2,…,ana_1, a_2, \ldots, a_n. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.

In one operation, you choose n−1n-1 elements of the array and replace each of them with their arithmetic mean (which doesn't have to be an integer). For example, from the array [1,2,3,1][1, 2, 3, 1] we can get the array [2,2,2,1][2, 2, 2, 1], if we choose the first three elements, or we can get the array [43,43,3,43][\frac{4}{3}, \frac{4}{3}, 3, \frac{4}{3}], if we choose all elements except the third.

Is it possible to make all elements of the array equal by performing a finite number of such operations?

给你一个包含 nn 个整数的数组 a1,a2,…,ana_1, a_2, \ldots, a_n。在观看了精彩绝伦的电影《瞬息全宇宙》后,你提出了如下操作。

一次操作中,你从数组中选出 n−1n-1 个元素,并将它们每个都替换为这 n−1n-1 个元素的算术平均值(该平均值不一定是整数)。例如,对于数组 [1,2,3,1][1, 2, 3, 1],若选择前三个元素,则可得到数组 [2,2,2,1][2, 2, 2, 1];若选择除第三个元素外的所有元素,则可得到数组 [43,43,3,43][\frac{4}{3}, \frac{4}{3}, 3, \frac{4}{3}]。

是否可以通过执行有限次此类操作,使得数组中所有元素均相等?

输入格式

The first line of the input contains a single integer tt (1≤t≤2001 \le t \le 200) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (3≤n≤503 \le n \le 50) — the number of integers.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤1000 \le a_i \le 100).

输入的第一行包含一个整数 tt(1≤t≤2001 \le t \le 200)—— 表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(3≤n≤503 \le n \le 50)—— 表示整数的个数。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤1000 \le a_i \le 100)。

输出格式

For each test case, if it is possible to make all elements equal after some number of operations, output YES\texttt{YES}. Otherwise, output NO\texttt{NO}.

You can output YES\texttt{YES} and NO\texttt{NO} in any case (for example, strings yEs\texttt{yEs}, yes\texttt{yes}, Yes\texttt{Yes} will be recognized as a positive response).

对于每个测试用例,如果经过若干次操作后可以使所有元素相等,则输出 YES\texttt{YES};否则输出 NO\texttt{NO}。

您可以以任意大小写形式输出 YES\texttt{YES} 和 NO\texttt{NO}(例如,字符串 yEs\texttt{yEs}、yes\texttt{yes}、Yes\texttt{Yes} 均被视为肯定回答)。

输入输出样例

  • 输入#1

    4
    3
    42 42 42
    5
    1 2 3 4 5
    4
    4 3 2 1
    3
    24 2 22

    输出#1

    YES
    YES
    NO
    NO

说明/提示

In the first test case, all elements are already equal.

In the second test case, you can choose all elements except the third, their average is 1+2+4+54=3\frac{1 + 2 + 4 + 5}{4} = 3, so the array will become [3,3,3,3,3][3, 3, 3, 3, 3].

It's possible to show that it's impossible to make all elements equal in the third and fourth test cases.

在第一个测试用例中,所有元素已经相等。

在第二个测试用例中,你可以选择除第三个元素外的所有元素,它们的平均值为 1+2+4+54=3\frac{1 + 2 + 4 + 5}{4} = 3,因此数组将变为 [3,3,3,3,3][3, 3, 3, 3, 3]。

可以证明,在第三和第四个测试用例中,无法使所有元素相等。

输入解题思路,AI测评打分。不知道怎么写?

首页