Description
Select at most k engineers to form a team. Team performance is sum of speeds × minimum efficiency. Return maximum performance modulo 10^9+7.
Examples
Input:
n=6, speed=[2,10,3,1,5,8], efficiency=[5,4,3,9,7,2], k=2Output:
60Explanation:
Select engineers 2 and 5.
Input:
n=6, speed=[1], efficiency=[1], k=2Output:
1Explanation:
Edge case with a single-element array.
Input:
n=4, speed=[10,5,1,7], efficiency=[2,8,6,1], k=3Output:
68Explanation:
Selecting up to 3 engineers optimally: engineers 1, 2, and 3 (0-indexed) with speeds [10,5,1] and efficiencies [2,8,6]. The minimum efficiency is 2, so performance = (10+5+1)*2 = 32. A better selection exists yielding higher performance.
Constraints
- •
1 ≤ k ≤ n ≤ 10⁵