Maximize Sum

0

0 votes
Problem

You are given two sets A,B(1-indexed) of equal size N and a number K.For every index i(1..N) we have to select either A[i] or B[i] ,such that sum of selected numbers is maximum and at most K elements from selected numbers are from set A.

Input Format

First line contains an integer N and K.

Next line contains elements of set A.

Third line contains elements of set B.

Output Format

Print single integer required answer.

Constraints

1<=N<=1e6

-1e9<=A[i]<=1e9

-1e9<=B[i]<=1e9

0<=K<=N

Sample Input
6 3 
7 11 6 4 13 19
1 2 3 4 5 6

Sample Output
51
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

From set A 19,13 and 11 are selected and from set B 1,3,4.

Total Sum =19+13+11+1+3+4=51 

Editor Image

?