Minimum Cost to Reach Every Position
For each position, the cheapest way to reach it is the smallest cost seen up to that point, so a running minimum answers every position in one pass.
For each position, the cheapest way to reach it is the smallest cost seen up to that point, so a running minimum answers every position in one pass.