Profitable Schemes - Problem
Criminal Organization Planning Challenge
You're managing a criminal organization with
• Generates
• Requires exactly
Important constraint: Each member can only participate in one crime - no member can be involved in multiple operations.
Your goal is to find how many different profitable schemes exist. A profitable scheme is any combination of crimes that:
1. Generates at least
2. Uses at most
Since the answer can be extremely large, return it
Example: With 3 members, minProfit=2, profits=[2,3,1], groups=[2,1,1]
You could choose crime 0 (profit=2, uses 2 members) OR crimes 1+2 (profit=4, uses 2 members) = 2 schemes
You're managing a criminal organization with
n members who need to plan their operations strategically. You have a list of potential crimes, where each crime i:• Generates
profit[i] money• Requires exactly
group[i] members to executeImportant constraint: Each member can only participate in one crime - no member can be involved in multiple operations.
Your goal is to find how many different profitable schemes exist. A profitable scheme is any combination of crimes that:
1. Generates at least
minProfit total profit2. Uses at most
n total membersSince the answer can be extremely large, return it
modulo 10^9 + 7.Example: With 3 members, minProfit=2, profits=[2,3,1], groups=[2,1,1]
You could choose crime 0 (profit=2, uses 2 members) OR crimes 1+2 (profit=4, uses 2 members) = 2 schemes
Input & Output
example_1.py — Basic Case
$
Input:
n = 5, minProfit = 3, group = [2,2], profit = [2,3]
›
Output:
2
💡 Note:
We can form 2 profitable schemes: choose crime 1 alone (profit=3, members=2) OR choose both crimes (profit=5, members=4). Both satisfy minProfit ≥ 3 and members ≤ 5.
example_2.py — Multiple Options
$
Input:
n = 10, minProfit = 5, group = [2,3,5], profit = [6,7,8]
›
Output:
7
💡 Note:
Multiple combinations work: {0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}. Each achieves profit ≥ 5 with members ≤ 10.
example_3.py — Edge Case
$
Input:
n = 1, minProfit = 1, group = [1,1,1], profit = [1,1,1]
›
Output:
3
💡 Note:
With only 1 member available, we can choose any single crime. Each crime uses exactly 1 member and generates profit 1, meeting our minimum requirement.
Constraints
- 1 ≤ n ≤ 100
- 0 ≤ minProfit ≤ 100
- 1 ≤ group.length ≤ 100
- 1 ≤ group[i] ≤ 100
- 0 ≤ profit[i] ≤ 100
- Note: Each member can participate in at most one crime
Visualization
Tap to expand
Understanding the Visualization
1
Setup Crew
You have n members available and need at least minProfit total
2
Evaluate Heists
Each heist has specific member requirements and profit potential
3
Dynamic Planning
Use DP to count all valid combinations efficiently
4
Count Schemes
Sum all ways that meet profit goal with available crew
Key Takeaway
🎯 Key Insight: Use 3D DP to efficiently count all valid combinations by tracking members used and minimum profit achieved, avoiding the exponential complexity of brute force enumeration.
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code