879. Profitable Schemes Hard
1/**
2 * [879] Profitable Schemes
3 *
4 * There is a group of n members, and a list of various crimes they could commit. The i^th crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can't participate in another crime.
5 * Let's call a profitable scheme any subset of these crimes that generates at least minProfit profit, and the total number of members participating in that subset of crimes is at most n.
6 * Return the number of schemes that can be chosen. Since the answer may be very large, return it modulo 10^9 + 7.
7 *
8 * Example 1:
9 *
10 * Input: n = 5, minProfit = 3, group = [2,2], profit = [2,3]
11 * Output: 2
12 * Explanation: To make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1.
13 * In total, there are 2 schemes.
14 * Example 2:
15 *
16 * Input: n = 10, minProfit = 5, group = [2,3,5], profit = [6,7,8]
17 * Output: 7
18 * Explanation: To make a profit of at least 5, the group could commit any crimes, as long as they commit one.
19 * There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2).
20 *
21 * Constraints:
22 *
23 * 1 <= n <= 100
24 * 0 <= minProfit <= 100
25 * 1 <= group.length <= 100
26 * 1 <= group[i] <= 100
27 * profit.length == group.length
28 * 0 <= profit[i] <= 100
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/profitable-schemes/
34// discuss: https://leetcode.com/problems/profitable-schemes/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn profitable_schemes(n: i32, min_profit: i32, group: Vec<i32>, profit: Vec<i32>) -> i32 {
40 0
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_879() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.