Fast and Careful Team
Worker i has a speed speeds[i] and a care score cares[i]. Choose a team of at least one and at most k workers. The score of a team is the sum of its speeds times the smallest care score on the team.
Return the best score a team can have.
Example 1
speeds [4,9,3]
cares [6,2,5]
k 2
returns 35
Workers 0 and 2 have speeds 4 + 3 = 7 and the smaller care score is 5: 35. The fast worker 1 would drag the care score down to 2.
Example 2
speeds [10,1]
cares [1,10]
k 2
returns 11
Both together: speeds 10 + 1 = 11, times the smaller care score 1. Either worker alone scores 10.
Constraints
1 <= k <= len(speeds) <= 300len(cares) == len(speeds)1 <= speeds[i], cares[i] <= 10**5
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.