#K43132. Student Score Ranking
Student Score Ranking
Student Score Ranking
In this problem, you are given the scores of students and you have to determine the rank of a specific student in each test case. For each test case, you are provided with an integer (n) representing the number of students, followed by a list of (n) integers (s_0, s_1, \dots, s_{n-1}) representing the scores, and an integer (m) which denotes the index (0-indexed) of the student whose rank you need to compute. The rank is defined as (1 + \text{number of scores strictly greater than } s_m ). Note that if several students have the same score, they share the same rank.
For example, consider the test case where (n = 5), scores = [100, 90, 90, 80, 70] and (m = 3). The score of the student at index 3 is 80. When the scores are sorted in non-increasing order, we receive [100, 90, 90, 80, 70]. There are three scores strictly greater than 80, so the rank is (3+1=4).
inputFormat
The first line of input contains an integer (T) representing the number of test cases. For each test case, the first line contains two integers (n) and (m) (the number of students and the index of the target student, respectively). The second line contains (n) space-separated integers representing the scores of the students.
outputFormat
For each test case, output a single line containing one integer — the rank (1-indexed) of the student at index (m).## sample
2
5 3
100 90 90 80 70
4 1
50 50 50 40
4
1
</p>