MicrosoftOA #5
Intern Tasks — Max Combined Reward Points
估计中等可在线判题
考点(AI 标注)贪心调度
All tasks must be assigned: the first person does exactly k tasks and the second person does the rest. Each task is done exactly once. Find the maximum total reward.
输入格式
The first line contains n k (1≤n≤100000, 0≤k≤n), the second line contains the first person's n rewards, and the third line contains the second person's n rewards, each in 1..10000.
输出格式
Output a single integer, the answer.
样例 1
输入:
5 3
5 4 3 2 1
1 2 3 4 5
输出:
21
样例 2
输入:
1 0
1
9
输出:
9
样例 3
输入:
1 1
1
9
输出:
1
样例说明
Example 1: the second person doing everything earns 15, and the 3 largest differences are 4, 2, 0, for a total of 21.
Example 2: k=0, so all tasks go to the second person, earning 9.
Example 3: k=1, so the first person must do the task, earning 1; it cannot be withheld from them just because the reward is lower.