Added printing the optimal cost