However, initial value of d should be profit of position id. There is a case when there is an optimal way not to take any restaurants to the right of id position, only current is enough. Consider, the following case: m = {1, 2} p = {1, 4}; k = 10; right answer is 4, not 1 :).
Also optimal solution doesn't always include first restraunt. I think the best way to use iterative version (bottom-up approach) of the DP. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.