#C2308. Equal Array Elements Check
Equal Array Elements Check
Equal Array Elements Check
You are given several test cases. For each test case, you are provided with an array of integers. Your task is to determine whether it is possible to make all elements of the array equal using the allowed operation. In this problem, the only operation allowed is to check the array as it is; you are not allowed to change any element. Essentially, if all elements are already the same, then output YES
, otherwise output NO
.
Observation: The condition for outputting YES
is that all the numbers in the array must be equal. This can be verified by checking if the size of the set of elements is one. Otherwise, output NO
.
Note: Input is taken from standard input (stdin) and output is printed to standard output (stdout).
inputFormat
The input begins with an integer T
(1 ≤ T ≤ 104) denoting the number of test cases. Each test case consists of two lines:
- The first line contains an integer
n
(1 ≤ n ≤ 105) representing the number of elements in the array. - The second line contains
n
space-separated integers.
The input is read from standard input (stdin).
outputFormat
For each test case, output a single line with either YES
if every element in the array is equal, or NO
otherwise. The result for each test case should be printed on a new line on standard output (stdout).
1
4
5 5 5 5
YES