Problem context and objectives
Mission briefing
Energy-route planner · A runner crosses a line of power stations
Build each decision from smaller outcomes already solved: The Linked Rewards.
Re-solving the same future branches drains exponential energy.
How you win
- 1Recognize when Delete and earn matches the clues
- 2Keep this true after every move: the rolling best includes every decision through the current distinct value
- 3Reach the result within O(n + u log u)
Rules and pressure
- Target cost: O(n + u log u)
- State rule: the rolling best includes every decision through the current distinct value
Lesson 1 of 3
Live algorithm trace
Delete and earn
Complete execution1 of 5
Aggregate three copies of value 3 into nine available points.
1
sum points by value2
sort distinct values3
for each value4
if consecutive: compare take with skip5
if gap: safely add current points6
return bestbuckets = 2:2,3:9,4:4
Truth to preserve / Cost target
Truth to preserve
the rolling best includes every decision through the current distinct value
Cost target
O(n + u log u)
Taking value x earns all copies of x but forbids x-1 and x+1. Aggregate points by numeric value, then run take-or-skip across the sorted value axis.
Your call · What should guide every step of this algorithm?