#C5091. Finding the Largest Group in Student Scores

    ID: 48702 Type: Default 1000ms 256MiB

Finding the Largest Group in Student Scores

Finding the Largest Group in Student Scores

You are given the scores of students in several test cases. For each test case, your task is to find the group of students with the same score that has the largest size. In the event of a tie (i.e. more than one score has the same maximum frequency), select the group with the highest score.

Example: Suppose one test case has 6 scores: 70, 80, 90, 90, 80, 70. The frequencies are: 70 appears 2 times, 80 appears 2 times, and 90 appears 2 times. Since there is a tie, we choose the highest score, which is 90. Thus, the answer is 2 90.

This problem will test your ability to work with frequency counts and handle tie-breaking conditions. All formulas are written in \(\LaTeX\). For instance, if the frequency of score \( s \) is \( f(s) \), you need to find \( \max_{s} f(s) \), and in case of ties, choose the maximum \( s \).

inputFormat

The first line of input contains an integer (T) representing the number of test cases. For each test case, the first line contains an integer (N) representing the number of students. The following line contains (N) integers separated by spaces, indicating the scores of the students.

outputFormat

For each test case, output two integers separated by a space: the size of the largest group of students with the same score and the corresponding score. In case of ties in group size, output the group with the highest score.## sample

1
5
50 50 50 50 50
5 50

</p>