Problem context and objectives
Mission briefing
Matchmaking coordinator · Urgent players and jobs compete for limited slots
Keep the best next candidate available without sorting everything again: The Capital Engine.
A stale priority frontier increases wait time for everyone.
How you win
- 1Recognize when Two-priority project selection matches the clues
- 2Keep this true after every move: the profit heap contains every unchosen project affordable with current capital
- 3Reach the result within O(n log n + k log n)
Rules and pressure
- Target cost: O(n log n + k log n)
- State rule: the profit heap contains every unchosen project affordable with current capital
Lesson 1 of 3
Live algorithm trace
Two-priority project selection
Complete execution1 of 6
c0:p1
project
c1:p2
c1:p3
Sort projects by the capital required to start them.
1
sort projects by required capital2
repeat at most k times3
push every newly affordable profit4
stop if no project is affordable5
pop maximum profit6
add profit to capital7
return capitalcapital = 0k = 2sorted = 0,1,1
Truth to preserve / Cost target
Truth to preserve
the profit heap contains every unchosen project affordable with current capital
Cost target
O(n log n + k log n)
Sort projects by required capital and move every currently affordable project into a max-heap of profits. Choosing the greatest available profit can only expand the set affordable next.
Your call · What should guide every step of this algorithm?