Universal Cup Judging System

Universal Cup

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

ICPC 2026 Chang’an Invitational Tournament 就快開始。有 $n$ 隊打算報名參賽,第 $i$ 隊會喺第 $v_i$ 秒瀏覽報名網站。

對每個正整數 $s$:

  • 如果喺第 $s$ 秒瀏覽報名網站嘅隊伍數目唔超過 $x$,咁喺第 $s$ 秒瀏覽嘅所有隊伍都會報名成功。

  • 否則,因為瀏覽嘅隊伍太多,報名網站會喺嗰一秒崩潰,而喺第 $s$ 秒瀏覽嘅所有隊伍都會報名失敗。

作為 ICPC 2026 Chang’an Invitational Tournament 嘅總裁判長,Yuki 想知道呢場比賽嘅報名情況。所以,你要幫佢計算成功報名嘅隊伍數目。

輸入格式

呢題包含多組測試資料。

第一行有一個正整數 $t$($1\le t\le10^5$),表示測試資料組數。

對每組測試資料:

  • 第一行有兩個正整數 $n,x$($1\le n\le2\cdot10^5$,$1\le x\le n$)。

  • 第二行有 $n$ 個正整數 $v_1,\ldots,v_n$($1\le v_i\le10^9$)。

保證所有測試資料嘅 $n$ 總和唔超過 $2\cdot10^5$。

輸出格式

對每組測試資料,輸出一行,包含一個整數,表示成功報名嘅隊伍數目。

例子

輸入格式 1

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

輸出格式 1

2
5
0

說明

對第一組測試資料:

  • 喺第 1 秒,第 1、4、5 隊瀏覽報名網站。因為 $3>2$,網站喺嗰一秒崩潰,呢 3 隊報名失敗。

  • 喺第 2 秒,第 2 隊瀏覽報名網站。因為 $1\le2$,網站冇崩潰,呢隊報名成功。

  • 喺第 3 秒,第 3 隊瀏覽報名網站。因為 $1\le2$,網站冇崩潰,呢隊亦都報名成功。

  • 總共有 2 隊報名成功,所以答案係 2。

對第二組測試資料:

  • 網站喺任何一秒都冇崩潰,全部 5 隊都報名成功,所以答案係 5。

對第三組測試資料:

  • 網站喺頭 3 秒嘅每一秒都崩潰,全部 6 隊都報名失敗,所以答案係 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.