#K68847. Max Tasks Completed by Knights
Max Tasks Completed by Knights
Max Tasks Completed by Knights
You are given several test cases. In each test case, there are n knights and m tasks. Each knight has a power level and each task requires a minimum power level to be completed.
A knight can complete a task if his power level P satisfies the condition \(P \geq T\), where \(T\) is the task's required power. Each knight can complete at most one task, and each task can be completed by at most one knight.
Your goal is to determine the maximum number of tasks that can be completed by matching knights to tasks in a greedy manner.
inputFormat
The input is given in the following format via stdin:
T n1 m1 p1 p2 ... pn1 T1 T2 ... Tm1 n2 m2 p1 p2 ... pn2 T1 T2 ... Tm2 ... (and so on for T test cases)
Here, T is the number of test cases. For each test case, the first line contains two integers n (the number of knights) and m (the number of tasks). The second line contains n integers representing the power levels of the knights. The third line contains m integers representing the required power levels for the tasks.
outputFormat
For each test case, output a single integer on a new line representing the maximum number of tasks that can be completed. The output is written to stdout.
## sample2
4 3
10 20 15 30
15 10 20
5 5
20 10 15 30 25
15 10 20 25 30
3
5
</p>