1383. Maximum Performance of a Team Hard
1/**
2 * [1383] Maximum Performance of a Team
3 *
4 * You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the i^th engineer respectively.
5 * Choose at most k different engineers out of the n engineers to form a team with the maximum performance.
6 * The performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers.
7 * Return the maximum performance of this team. Since the answer can be a huge number, return it modulo 10^9 + 7.
8 *
9 * Example 1:
10 *
11 * Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2
12 * Output: 60
13 * Explanation:
14 * 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.
15 *
16 * Example 2:
17 *
18 * Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3
19 * Output: 68
20 * Explanation:
21 * 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.
22 *
23 * Example 3:
24 *
25 * Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4
26 * Output: 72
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= k <= n <= 10^5
32 * speed.length == n
33 * efficiency.length == n
34 * 1 <= speed[i] <= 10^5
35 * 1 <= efficiency[i] <= 10^8
36 *
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/maximum-performance-of-a-team/
41// discuss: https://leetcode.com/problems/maximum-performance-of-a-team/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46 pub fn max_performance(n: i32, speed: Vec<i32>, efficiency: Vec<i32>, k: i32) -> i32 {
47 0
48 }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_1383() {
59 }
60}
61
Back
© 2025 bowen.ge All Rights Reserved.