The real wordsTheory
Delivered cost is the number that matters
Production cost alone will mislead you, and so will transport cost alone. Add them.
Delivered cost (plant i to market j) = production cost at i + transport cost i to j
Baddi produces at 525, the cheapest of the five. It delivers to Bangalore at 525 + 511 = 1,036, the dearest of the five. Cheap to make is not cheap to sell.
Build the whole delivered-cost matrix first. Every later step reads off it.