Maximum Performance of a Team

Given engineers with speed and efficiency, choose up to k engineers to maximize speed sum multiplied by the minimum efficiency among selected engineers. The optimal solution sorts by efficiency and uses a max heap of speeds.

Input Format

speed and efficiency arrays, k max team size

Output Format

maximum performance modulo 1,000,000,007 if required by judge

Constraints

  • 1 <= speed.length = efficiency.length <= 10^5
  • 1 <= speed[i], efficiency[i] <= 10^8
  • 1 <= k <= speed.length

Examples

Example 1:

Input:

speed = [2,10,3,1,5,8]
efficiency = [5,4,3,9,7,2]
k = 2

Output:

60

Explanation:

The best team gives performance 60.

Example 2:

Input:

speed = [2,10,3,1,5,8]
efficiency = [5,4,3,9,7,2]
k = 3

Output:

68

Explanation:

With three engineers, the best performance increases to 68.

Loading...
Maximum Performance of a Team - Heap DSA Problem