Divide Students Into Classes solution codechef

Divide Students Into Classes solution codechef

You are given the heights of nn students who want to attend a school. The school, being weird as usual, has a condition that all the students in a class should have the same height. Also, the school runs only 12 classes from class 1 to class 12.

Find out whether it is possible for you to divide all the nn students into 12 classes. Note that in each class, there should be at least one student, and the heights of all the students should be equal. Multiple classes can have students with the same height also.

Input Divide Students Into Classes solution codechef

  • The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The first line of each test case contains an integer nn.
  • The second line contains nn space-separated integers h1,h2,,hnh1,h2,…,hn denoting the heights of the students.

Output Divide Students Into Classes solution codechef

For each test case, print a single line containing “yes” or “no” (without quotes) depending on the situation.

Constraints

  • 1T101≤T≤10
  • 1n1051≤n≤105
  • 1hi1051≤hi≤105

Subtasks

Sample Input

3
3
1 2 3
12
1 2 3 4 5 6 7 8 9 10 11 12
14
1 1 1 1 1 1 1 1 1 1 1 1 1 1

Sample Output Divide Students Into Classes solution codechef

no
yes
yes

Explanation

Example case 1: There are only three students. So there is no way that there can be at least one student in each class.

Example case 2: There are only twelve students. Each student can go into a separate class.

Example case 3: There are total fourteen students. One way of dividing them into classes will be class 1 to 10, one student each. While 11th and 12th class have two each.

Leave a Comment

Your email address will not be published. Required fields are marked *