Universal Cup Judging System

Universal Cup

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓
Statistiques

The ICPC 2026 Chang’an Invitational Tournament is about to begin. There are $n$ teams planning to register for the competition, where the $i$-th team will visit the registration website at the $v_i$-th second.

For every positive integer $s$:

  • If the number of teams visiting the registration website at the $s$-th second is no more than $x$, then all teams visiting at the $s$-th second register successfully.

  • Otherwise, the registration website crashes at that second due to too many teams visiting, and all teams visiting at the $s$-th second fail to register.

As the chief judge of the ICPC 2026 Chang’an Invitational Tournament, Yuki wants to know the registration status of this competition. Therefore, you need to help her calculate the number of teams that successfully register.

Input

This problem contains multiple test cases.

The first line contains a positive integer $t$ ($1\le t\le10^5$), representing the number of test cases.

For each test case:

  • The first line contains two positive integers $n,x$ ($1\le n\le2\cdot10^5$, $1\le x\le n$).

  • The second line contains $n$ positive integers $v_1,\ldots,v_n$ ($1\le v_i\le10^9$).

It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot10^5$.

Output

For each test case, output a single line containing an integer representing the number of teams that successfully register.

Examples

Input 1

3
5 2
1 2 3 1 1
5 2
3 1 4 1 5
6 1
2 3 1 3 1 2

Output 1

2
5
0

Note

For the first test case:

  • At the 1-st second, teams 1, 4, 5 visited the registration website. Since $3>2$, the website crashed at this second, and these 3 teams failed to register.

  • At the 2-nd second, team 2 visited the registration website. Since $1\le2$, the website did not crash, and this team registered successfully.

  • At the 3-rd second, team 3 visited the registration website. Since $1\le2$, the website did not crash, and this team also registered successfully.

  • A total of 2 teams registered successfully, so the answer is 2.

For the second test case:

  • The website did not crash at any second, all 5 teams registered successfully, so the answer is 5.

For the third test case:

  • The website crashed in each of the first 3 seconds, all 6 teams failed to register, so the answer is 0.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.