determining minimum cost output using computed costs