dynamic programming -- cutrod