#3767
Maximize Points After Choosing K Tasks
medium · 60% accepted · 66 likes · top 58%
array · greedy · sorting · heap (priority queue)
Description
You are given two integer arrays, technique1 and technique2, each of length n, where n represents the number of tasks to complete.
- If the ith task is completed using technique 1, you earn technique1[i] points.
- If it is completed using technique 2, you earn technique2[i] points.
You are also given an integer k, representing the minimum number of tasks that must be completed using technique 1.
You must complete at least k tasks using technique 1 (they do not need to be the first k tasks).
The remaining tasks may be completed using either technique.
Return an integer denoting the maximum total points you can earn.
Solution