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