Maximum Team Performance with a Size Limit. Choose at most k of the n engineers. A team's performance is the sum of its members' speeds multiplied by the smallest efficiency among those members.
### Problem
Choose at most k of the n engineers. A team's performance is the sum of its members' speeds multiplied by the smallest efficiency among those members. Return the largest possible performance modulo 1000000007; optimize the true performance before applying the modulus.
```cpp
class Solution {
public:
int maxPerformance(int n, vector<int>& speed, vector<int>& efficiency, int k);
};
```
### Examples
**Example 1:**
```text
Input: n = 3, speed = [2,4,3], efficiency = [5,2,4], k = 2
Output: 20
Explanation: Engineers0 and2 have total speed5 and minimum efficiency4, giving20; every pair involving engineer1 gives at most14.
```
**Example 2:**
```text
Input: n = 2, speed = [5,1], efficiency = [2,10], k = 1
Output: 10
Explanation: Either single engineer has performance10, and the size limit forbids taking both.
```
### Constraints
- `1 <= k <= n <= 100000`; speed and efficiency each have length n.
- `1 <= speed[i] <= 100000` and `1 <= efficiency[i] <= 100000000`.
### Contract considerations
Both input arrays describe the same engineer indices. Return only the optimal value modulo the stated modulus.
```hint Read the boundary condition
Respect the team-size limit and the speed/efficiency pairing. Compare true performance values before producing the modular result.
```
### Boundary reminders
Both input arrays describe the same engineer indices. Return only the optimal value modulo the stated modulus.
Overview: Maximum Team Performance with a Size Limit. Choose at most k of the n engineers. A team's performance is the sum of its members' speeds multiplied by the smallest efficiency among those members.
Choose at most k of the n engineers. A team's performance is the sum of its members' speeds multiplied by the smallest efficiency among those members. Return the largest possible performance modulo 1000000007; optimize the true performance before applying the modulus.
class Solution {
public:
int maxPerformance(int n, vector<int>& speed, vector<int>& efficiency, int k);
};
Examples
Example 1:
Input: n = 3, speed = [2,4,3], efficiency = [5,2,4], k = 2
Output: 20
Explanation: Engineers0 and2 have total speed5 and minimum efficiency4, giving20; every pair involving engineer1 gives at most14.
Example 2:
Input: n = 2, speed = [5,1], efficiency = [2,10], k = 1
Output: 10
Explanation: Either single engineer has performance10, and the size limit forbids taking both.
Constraints
1 <= k <= n <= 100000
; speed and efficiency each have length n.