Link. There is no AC solution for this problem, neither I could find any blog/post related to it. If anyone can give some hint/idea, that would be of much help.
Poor, lonely problem :(:
It’s actually a fairly straightforward DP problem - solution is here.
I’ll come back and document it better later, but for now should be plenty of “hints” in there to get you started!
Can you please explain your approach?
Thank you so much @ssjgz !
You named varibales so well there was no need of comments. Thanks again. and yeah it was a simple dp problem, unfortunately I could not come up with the proper dp states.