Faced this problem in practice area : Problem
It seems like a general DP problem but I could not figure out its solution.I also tried finding its editorial but there seem to be no resource available for this problem.I tried seeing solutions of others but they were impossible to understand until I know what does DP array in their solution represent.
So please help me.Any small hint will also do fine. Thanks in advance. :)