479. ACB Round 1

Problem Statement:
A2OJ Code Battle (by WUZZUF) is a new programming contest, it's the first Egyptian individual contest with lots of prizes provided by WUZZUF.

It's first round is a special one, because it's a 24-hour round, so it will be unfair to consider the time penalty in a 24-hour round.

To solve this issue, here's the rule for qualifying users from the first round: The top M contestants will be qualified to the next round, plus anyone else who solved the same number of problems as the Mth contestant, but no one will be qualified if they don't solve anything correctly.

The contestants are ranked based on how many problems they solved, who solved more gets a higher rank. When X contestant solve the same number of problems, they get the next X ranks in any order, it doesn't matter in this problem.

Given how many problems were solved by each contestant, and the value of M, determine how many contestants will be qualified to the next round.

Input Format:
Your program will be tested on one or more test cases. The first line of the input will be a single integer T (1 ≤ T ≤ 100) representing the number of test cases. Followed by T test cases.

Each test case starts with a line containing 2 integers separated by a space, N (the number of contestants, 1 ≤ N ≤ 100), M (the value of M as described above, 1 ≤ MN).

Followed by N lines, each line represents a contestant and contains a single integer which is the number of problems that contestant solved. These numbers are not sorted in any way

Output Format:
For each test case print a single line containing just one integer which is the number of contestants who will be qualified to the next round.

Sample Input:
3 5 2 1 2 3 7 6 5 3 7 7 5 5 3 5 4 0 0 3 2 1

Sample Output:
2 4 3

Notes:
In the first case, the contestants solving 7 problems and 6 problems are qualified.

In the second test case, the contestants solving 7 problems and 5 problems are qualified, here we are qualifying more than M contestants because there's a tie at the Mth place with 5 problems, so both are qualified, and the contestants solving 7 problems are given the 1st and 2nd places.

In the third test case, there's less than M contestants with positive number of solved problems, so only 3 contestants will be qualified.

 Added by: ahmed_aly Added at: 2017-10-09 20:00:00 UTC Time Limit: 2 seconds Partial score: No Source: A2OJ Code Battle Round 1