Operation Dilemma

5

2 votes
Data Structures, Priority queue, Trees
Problem

You are given 2 integers arrays A and B of size N, for every index i, you could either add Bi to Ai or subtract Bi from Ai, you are only allowed to do atmost K add operations. For a subarray of size L print the largest possible sum after doing the above operations.

Input format

  • The first line contains T, denoting the number of test cases.
  • First line of each test case contains N,L,K denoting the size of the array, length of the subarray and the number of operations.
  • Then the next line contains N integers, denoting the element of array A.
  • Then the next line contains N integers, denoting the element of array B.

Output format

  • Print a integer denoting the largest possible sum after doing the above operations

Constraints

1N105

1KLN

109Ai,Bi109

The sum of N over all test case does not exceed 2105

Sample Input
1
5 5 2
1 2 3 4 5
-1 2 3 4 5
Sample Output
20
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Here we can use add operation on 4 and 5, and subtract the rest of them.

Contributers:
Editor Image

?