You are given two arrays, \(A\) and \(B\) of length \(N\). In one operation, you can swap \(A[i]\) and \(B[i]\). Find the maximum sum of \(A\) after performing at most \(K\) operations.
Input format
- The first line contains an integer \(T\), denoting the number of test cases.
- The first line of each test case contains two integers, \(N\) and \(K\).
- The second line of each test case contains \(N\) space-separated integers, elements of array \(A\).
- The third line of each test case contains \(N\) space-separated integers, elements of array \(B\).
Output format
For each test case, print the maximum sum of \(A\) after performing at most \(K\) operations in a new line.
Constraints
For test case \(1\): We can perform the operations at indexes 2, 4, and 5 (1-based indexing). \(A\) becomes \([1, 4, 1, 6, 5].\) Hence, the answer is \(17\).
For test case \(2\): We can perform the operations at index 1 (1-based indexing). \(A\) becomes \([3, 5, 1]\). Hence, the answer is \(9\).
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