After dynamic programming correctly implemented