dynamic programming + probability