There are \(N\) sports in a college sports fest. There are 2 players A and B, each of the \(N\) sports will be chosen by one of them and points that A will get by playing sport i is \(X_i\) while that of B is \(Y_i\). Now, choice filling has started and A will choose first and each player will be choosing one sport alternatively until they choose all. A and B are rivals and want their score (Sum of A's points - sum of B's score) to be maximized. Find the score of A if they both play optimally.
Input format
- The first line contains an integer \(T\) denoting the number of test cases.
- The first line of each test case contains an integer \(N\) denoting the number of sports.
- The second line contains \(N\) space-separated integers of array X.
- The third line contains \(N\) space-separated integers of array Y.
Output format
For each test case, print a single line containing the score of A.
Constraints
- \(1 \leq T \leq 20000\)
- \(1 \leq N \leq 200000\)
- \(1 \leq X_i,Y_i \leq 10^9\)
- Sum of \(N\) over all test cases will not exceed 200000
1 3 1 4 5 2 2 3
4
A will choose the third sport, B will choose second and A will sum up with first.
Points of A=5+1=6 and B=2. So A's score=6-2=4. Note that this is optimal.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor