Citadel interview question

Minimum Costs Using the Train Line