QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 256 MB Points totaux : 100

#11948. 恋人

Statistiques

有一天,$n$ 个女孩和 $n$ 个男孩来到西安寻找伴侣。每个女孩都有一个价值,第 $i$ 个女孩的价值记为 $a[i]$。每个男孩也有一个价值,第 $j$ 个男孩的价值记为 $b[j]$。第 $i$ 个女孩和第 $j$ 个男孩可以相爱,当且仅当 $a[i]+b[j] \ge k$,其中 $k$ 是一个已知的系数。

在本题中,你需要通过帮助他们选择伴侣,使得配对的恋人数量尽可能多,且每个人最多只能选择一个伴侣。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 5$),表示测试用例的数量。

接下来是 $T$ 个测试用例。每个测试用例的第一行包含两个整数 $n$ 和 $k$,其中 $1 \le n \le 200000$ 且 $0 \le k \le 10^9$。第二行包含 $n$ 个整数,表示 $a[1]$ 到 $a[n]$ 的值 ($0 \le a[i] \le 10^9$)。第三行包含 $n$ 个整数,表示 $b[1]$ 到 $b[n]$ 的值 ($0 \le b[i] \le 10^9$)。

输出格式

对于每个测试用例,在一行中输出答案。

样例

样例输入 1

1
3 4
1 2 3
1 2 3

样例输出 1

3

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.