#P17147. [ICPC 2017 Xi'an R] Lovers

    ID: 16753 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>贪心2017排序ICPC双指针 two-pointer西安

[ICPC 2017 Xi'an R] Lovers

题目描述

One day nn girls and nn boys come to Xi’an to look for a mate. Each girl has a value a[i]a[i], each boy has a value b[i]b[i]. Girl ii and boy jj will fall in love only if a[i]+b[j]≥ka[i] + b[j] \ge k.

Please help them make pairs as many as possible.

输入格式

Several test cases.

First line an integer TT (1≤T≤101 \le T \le 10). Indicates the number of test cases.

Then TT test cases follow. Each test case begins with two integers NN, KK (1≤N≤200000, 0≤K≤1091 \le N \le 200000,\ 0 \le K \le 10^9). The next line has NN integers indicating a[1]a[1] to a[N]a[N] (0≤a[i]≤1090 \le a[i] \le 10^9). The next line has NN integers indicating b[1]b[1] to b[N]b[N] (0≤b[i]≤1090 \le b[i] \le 10^9).

输出格式

For each test case, print the answer in a single line.

1
3 4
1 2 3
1 2 3
3