SOLVE
LATER
There are lots of contest coming up on HackerEarth and it is in urgent need of lots of problems. So it calls a meeting of all the problem setters in the team.
There are N problem setters in HackerEarth. Everybody has a fixed price for preparing a problem. This is given by the array prices[ ] and all elements of the array are distinct. Obviously the higher charged setters are more experienced and can easily do the task assigned to its lower charged setters.
The contest moderator AltF4, assigns a certain number of tasks to each of the setter. This is given by the array tasks[ ]. The finance team calculates the total cost to the company as sum of price[i] * tasks[i] for all i
.
This was simple. But the setters have now grown greedy. They need extra incentives to meet their busy schedule, transportation and accommodation costs. So everybody decides that if HackerEarth needs them and invites them to create problems, they would charge for extra K tasks to meet these surcharges.
For example if N = 2, prices of the setters are {10, 50} and AltF4 needs tasks from both as {10, 20} the cost to company would have been 10 x 10 + 50 x 20 = 1100. With the new law of surcharges with K = 10, there are 2 possibilities.
However, if K would have been 50, then analyzing the two possiblities:
Given the N, K, and the arrays prices[ ] and tasks[ ], your job is the help the finance team calculate the minimum cost possible for the company for doing all tasks.
Input & Output:
The first line contains the number of test cases T. The first line of every test case contains two integers N K separated by space. The next two lines contains the arrays prices and tasks respectively. All numbers are space separated.
For each test case, output the minimum possible cost to the company and help the finance team.
Constraints:T ≤ 25 1 ≤ N, prices[i], tasks[i] ≤ 2000 0 ≤ K ≤ 2000
Provided in the problem statement.