MathWorksOA #11
Task Completion
简单可在线判题
考点(AI 标注)贪心调度
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.
输入格式
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 the maximum total reward.
样例 1
输入:
5 3
5 4 3 2 1
1 2 3 4 5
输出:
21
样例 2
输入:
4 2
2 3 4 2
1 1 1 1
输出:
9
样例 3
输入:
2 0
3 3
4 2
输出:
6