Imagine you have two hungry mice and n different types of delicious cheese spread out before them. Each cheese must be eaten by exactly one mouse - no sharing allowed!
Here's the twist: each mouse has different taste preferences! For cheese i, the first mouse gets reward1[i] points of satisfaction, while the second mouse gets reward2[i] points.
Your goal: Distribute the cheese optimally so that the first mouse eats exactly k types of cheese, and the total satisfaction points are maximized.
Example: If reward1 = [1,1,3,4], reward2 = [4,4,1,1], and k = 2, the optimal strategy is to give cheese types 2 and 3 to the first mouse (earning 3+4=7 points) and types 0 and 1 to the second mouse (earning 4+4=8 points), for a total of 15 points.
Input & Output
Constraints
- 1 โค n โค 105
- 1 โค reward1[i], reward2[i] โค 1000
- 0 โค k โค n
- Each cheese must be eaten by exactly one mouse