Task Completion
Two interns at HackerRank are teamed up to complete a total of n tasks. Each task is to be completed by either of the two interns. Both interns have their reward points defined, where the first intern gains reward_1[i] points for completing the ithth task, while the second intern gains reward_2[i] points for completing the ithth task.
Since the interns work as a team, they wish to maximize the total reward points gained by both of them combined. Find the maximum combined reward points that can be gained if the first intern has to complete k tasks, and the second intern completes the remaining tasks.
Note: The k tasks completed by the first intern could be any amongst the n tasks.
Complete the function getMaximumRewardPoints in the editor.
getMaximumRewardPoints has the following parameters:
- 1.
int k: the number of tasks that have to be completed by intern 1 - 2.
int reward_1[n]: the reward points earned by intern 1 for each task - 3.
int reward_2[n]: the reward points earned by intern 2 for each task
Returns
int: the maximum possible combined reward points when intern 1 completes exactly k tasks
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
n ≤ 105k ≤ nreward_1[j] ≤ 104reward_2[j] ≤ 104