I think this problem is a DP problem too. Google Code Jam Round 1A has a similar problem in this year. http://code.google.com/codejam/contest/dashboard?c=544101#s=p1
In the contest analysis page. It also explains the detail. http://code.google.com/codejam/contest/dashboard?c=544101#s=a&a=1 -- 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.