Compute cost from the highest row