Can anyone please tell me how to solve this http://www.spoj.com/problems/HKNAP/ problem. I was thinking about 3-D DP approach. Does anyone have the better hints for the problem