#P9509. 『STA - R3』Aulvwc
『STA - R3』Aulvwc
Background
Statistics is an old and fascinating subject.
It is said that many years ago, a god named Huipu came to Earth and discovered humans, another intelligent species.
Hack testdata has been added in Subtask 5 and is not scored.
Problem Description
A sequence is defined to be partition-averagable if and only if there exists a partition of (where ) such that for every integer , the average of the elements in sequence whose indices are in are all the same integer.
Now, given the sequence , determine whether it is partition-averagable.
If some definitions are not very clear to you, you can refer to the “Hint” section at the end.
Input Format
The first line contains a positive integer , which represents the number of queries.
For each query, the first line contains a positive integer , describing the length of the sequence. The second line contains integers, representing the sequence .
Output Format
Output lines. For each query, if the sequence is partition-averagable, output Yes; otherwise, output No.
4
5
1 1 1 1 1
5
1 2 3 4 5
5
1 1 1 1 6
5
-1 0 1 0 1
Yes
Yes
No
No
Hint
Hint
A partition of a set is defined as a collection of sets , satisfying:
- For all , .
- .
The average of a sequence is defined as:
$$\bar x=\dfrac{x_1+x_2+\cdots+x_n}{n}=\dfrac 1n\sum_{i=1}^nx_i$$Sample Explanation
One possible partition for the first group of testdata: .
One possible partition for the second group of testdata: .
Note: the sets provided in a partition are sets of indices.
Constraints
This problem uses bundled testdata and subtask dependencies.
$$\newcommand{\arraystretch}{1.5} \begin{array}{c|c|c|c|c}\hline\hline \textbf{Subtask} & \bm{n}\le & \textbf{Score} & \textbf{Special Property}&\textbf{Dependent Subtasks}\\\hline \textsf{1} & 10 & 5 & \\\hline \textsf{2} & 10^3 & 20 & \sum a_i=0 \\\hline \textsf{3} & 100 & 25 & & \sf1\\\hline \textsf{4} & 10^3 & 50 & & \sf1\texttt{,}\ 3\\\hline \end{array}$$For all testdata, , , .
Translated by ChatGPT 5