GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 25 May 2022

[Solution] Everything Everywhere All But One Codeforces Solution | Codeforces Problem Solution 2022

A. Everything Everywhere All But One
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array of n integers a1,a2,,an. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.

In one operation, you choose n1 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] we can get the array [2,2,2,1], if we choose the first three elements, or we can get the array [43,43,3,43], if we choose all elements except the third.

Solution Click Below:-  CLICK HERE

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

Input
The first line of the input contains a single integer t (1t200)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n (3n50)  — the number of integers.
The second line of each test case contains n integers a1,a2,,an (0ai100).
Output

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

You can output YES and NO in any case (for example, strings yEsyesYes will be recognized as a positive response).

No comments:

Post a Comment