cswork / OAOpen practice workspace

MathWorksOA #11

Task Completion

EasyJudge-ready

Topics (AI-labelled)Greedy

Two people split n tasks. Giving task i to the first person earns reward_1[i], and giving it to the second person earns reward_2[i]. The first person must do exactly k tasks; find the maximum total reward of the two. The source's example 1 output of 21 is correct, but the arithmetic in its written explanation is contradictory; this site corrects the explanation according to the statement and the output.

See below for this site's input/output protocol.

Input

The first line contains n k, followed by two lines of n integers each: reward_1 and reward_2. 1≤n≤100000, 0≤k≤n, and every reward is 1..10000.

Output

Output the maximum total reward.

Example 1

Input:

5 3
5 4 3 2 1
1 2 3 4 5

Output:

21

Example 2

Input:

4 2
2 3 4 2
1 1 1 1

Output:

9

Example 3

Input:

2 0
3 3
4 2

Output:

6

Editorial

Loading solution…