
You are given N = ‘3’, M = ‘5’.
servers = { 8, 8, 32 }
tasks = { 4, 4, 8, 12, 16 }
The answers will be true because :
Task 1 and task 2 can be assigned to server 1.
Task 3 can be assigned to server 2.
Task 4 and task 5 can be assigned to server 3.
In this way, we can schedule all the given tasks.
The first line contains an integer 'T' which denotes the number of test cases.
The first line of each test case contains two space-separated integers, ‘N’ and ‘M’, representing the number of servers and tasks, respectively.
The second line of each test case contains ‘N’ space-separated integers denoting the memory limit of each server.
The third line of each test case contains ‘M’ space-separated integers denoting the memory required to assign each task.
For each test case, print “true” if all the tasks can be scheduled. Otherwise, print “false”.
The output of each test case will be printed in a separate line.
1 <= T <= 10
1 <= N, M <= 8
1 <= servers[i] <= 10^9
1 <= tasks[i] <= 10^9
Time limit: 1 sec
You do not need to input or print anything, as it has already been taken care of. Just implement the given function.
In this approach, we will try every possible combination using DFS. For each task, we will try to assign it to each server. We will check if all tasks are scheduled, then we will return true. Otherwise, we will return false.
Algorithm: