#P17298. [ICPC 2026 Xi'an I] Registration

    ID: 19708 远端评测题 1000ms 512MiB 尝试: 37 已通过: 15 显示难度普及− 上传者: 标签>模拟ICPC2026省赛/邀请赛STL西安

[ICPC 2026 Xi'an I] Registration

Problem Description

The ICPC 2026 Chang'an Invitational Tournament is about to begin. There are nn teams planning to register for the competition, where the ii-th team will visit the registration website at the viv_i-th second.

For every positive integer ss:

  • If the number of teams visiting the registration website at the ss-th second is no more than xx, then all teams visiting at the ss-th second register successfully.
  • Otherwise, the registration website crashes at that second due to too many teams visiting, and all teams visiting at the ss-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 Format

This problem contains multiple test cases.

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

For each test case:

  • The first line contains two positive integers n,xn, x (1n2105, 1xn)(1 \le n \le 2\cdot10^5,\ 1 \le x \le n).
  • The second line contains nn positive integers v1,,vnv_1, \dots, v_n (1vi109)(1 \le v_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 21052\cdot10^5.

Output Format

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

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

Hint

For the first test case:

  • At the 11-st second, teams 1,4,51,4,5 visited the registration website. Since 3>23 > 2, the website crashed at this second, and these 33 teams failed to register.
  • At the 22-nd second, team 22 visited the registration website. Since 121 \le 2, the website did not crash, and this team registered successfully.
  • At the 33-rd second, team 33 visited the registration website. Since 121 \le 2, the website did not crash, and this team also registered successfully.
  • A total of 22 teams registered successfully, so the answer is 22.

For the second test case:

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

For the third test case:

  • The website crashed in each of the first 33 seconds, all 66 teams failed to register, so the answer is 00.