

1) The dish will be delivered by a courier from the restaurant ‘i’, in this case, the courier will arrive in A[i] minutes,
2) Radhika goes to the restaurant ‘i’ on her own and picks up the dish, she will spend B[i] minutes on this.
The first line contains an integer 'T' which denotes the number of test cases. Then the test cases follow.
The first line of each test case contains an integer ‘N’ denoting the number of dishes that Radhika wants to order.
The second line of each test case contains ‘N’ space separated integers denoting the elements of array ‘A’.
The second line of each test case contains ‘N’ space separated integers denoting the elements of array ‘B’.
For each test case output an integer denoting the minimum time after which all dishes can be at Radhika’s home.
The output of each test case is printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
1 <= A[i] <= 500
1 <= B[i] <= 500
Where A[i] is the time of courier delivery of the dish with the number, and B[i] is the time during which Radhika will pick up the dish with the number.
Time Limit: 1 sec
Note that:
Therefore, we can find the minimum time after which all dishes can be at Radhika’s home by keeping track of the sum of pickup times till it's less than the delivery time. If, at any moment, delivery time is more than the sum of the pick up times, just return the maximum of delivery time and sum of pick up times. This is because, remaining dishes can be ordered at the same time as couriers work in parallel.
Algorithm:
Student Percentile Calculation
Player Leaderboard Sorting
Minimized Maximum of Products Distributed to Any Store
Minimal Character Reassignment
Unique Gift Packing