java.lang.Object
g1301_1400.s1383_maximum_performance_of_a_team.Solution

public class Solution extends Object
1383 - Maximum Performance of a Team.<p>Hard</p> <p>You are given two integers <code>n</code> and <code>k</code> and two integer arrays <code>speed</code> and <code>efficiency</code> both of length <code>n</code>. There are <code>n</code> engineers numbered from <code>1</code> to <code>n</code>. <code>speed[i]</code> and <code>efficiency[i]</code> represent the speed and efficiency of the <code>i<sup>th</sup></code> engineer respectively.</p> <p>Choose <strong>at most</strong> <code>k</code> different engineers out of the <code>n</code> engineers to form a team with the maximum <strong>performance</strong>.</p> <p>The performance of a team is the sum of their engineers&rsquo; speeds multiplied by the minimum efficiency among their engineers.</p> <p>Return <em>the maximum performance of this team</em>. Since the answer can be a huge number, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2</p> <p><strong>Output:</strong> 60</p> <p><strong>Explanation:</strong></p> <p>We have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3</p> <p><strong>Output:</strong> 68</p> <p><strong>Explanation:</strong></p> <p>This is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4</p> <p><strong>Output:</strong> 72</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= k <= n <= 10<sup>5</sup></code></li> <li><code>speed.length == n</code></li> <li><code>efficiency.length == n</code></li> <li><code>1 <= speed[i] <= 10<sup>5</sup></code></li> <li><code>1 <= efficiency[i] <= 10<sup>8</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maxPerformance

      public int maxPerformance(int n, int[] speed, int[] efficiency, int k)