#C7557. Task Assignment Optimization
Task Assignment Optimization
Task Assignment Optimization
You are given a list of tasks and a list of team members. Each task has an associated difficulty level and each team member can only complete tasks up to a certain maximum difficulty. Your goal is to determine the maximum number of tasks that can be assigned such that a task is assigned to a team member only if the task's difficulty is less than or equal to that member's capacity.
In other words, for each task with difficulty t and a team member with maximum capacity m, the task can be assigned if and only if:
\( t \leq m \)
You must use a greedy strategy: sort both the list of tasks and the team members, then assign the lowest difficulty available task to the first member that can handle it.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each test case consists of the following:
- An integer N denoting the number of tasks.
- A line with N space-separated integers representing the difficulty levels of each task.
- An integer M denoting the number of team members.
- A line with M space-separated integers representing the maximum difficulty each team member can handle.
outputFormat
For each test case, output a single integer on a new line representing the maximum number of tasks that can be assigned to team members under the given constraints.
## sample1
3
2 4 3
2
3 1
1
</p>