You are given an array of size N, denoting capacity of N boxes, and an integer K, denoting extended capacity factor. You are also given the weights of M balls. Each \(i^{th}\) box can accommodate exactly one ball having weight in range \([capacity_i, capacity_i+K]\) (both inclusive). Find the maximum number of boxes that can be filled.
Constraints:
- \(1 ≤ T ≤ 50\)
- \(1 ≤ N,M ≤ 10000\)
- \(1 ≤ K ≤ 1000\)
- \(1 ≤ Capacity_i ≤ 1000\)
- \(1 ≤ Weight_i ≤ 2000\)
Input format:
First line: T i.e. Number of test cases.
For each test case:
First line: Three space-separated integers N, M and K.
Second line: N space-separated integers denoting the capacity of boxes.
Third line: M space-separated integers denoting the weight of balls.
Output format:
For each test case, print the answer in a separate line.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial