

Let’s say the age of players is [1,2,6,4] and the skill of players is [1,2,3,4]. We cannot take all players in the team as 3rd player is older than 4th player but 4th player has strictly greater skill than 3rd player. Therefore we can take anyone among them. Therefore the highest total skill of team which is possible is 7.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case contains a single integer ‘N’ representing the number of players.
The second line of each test case contains ‘N’ single space-separated integers representing the age of players.
The third line of each test case contains ‘N’ single space-separated integers representing the skill of players.
For each test case, print a single integer denoting the highest total skill of the team which is possible.
The output of each test case will be printed in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 100
1 <= ‘AGE[i]’ <= 10^3
1 <= ‘SKILL[i]’ <= 10^6
Time Limit: 1 sec
Make an auxiliary vector/list ‘player’ which store age as its first parameter and skill as the second parameter. Sort the list with age as a priority and if age is the same then on basis of skill. Then iterate over all the possible teams recursively.
We will apply the algorithm as follows:-
Make an auxiliary vector/list ‘PLAYER’ which store age as its first parameter and skill as the second parameter. Sort the list with age as a priority and if age is the same then on basis of skill. We will also maintain array/list 'DP' where ‘DP[i]’ stores the maximum total skill of the team from ‘i’ players if the ith player was taken in the team.
Following is the algorithm for this approach: