• + 0 comments

    This problem is definitely easier than a fair number of the medium-rated DP problems. At least in this case it's obvious how to relate the desired solution to the solution to a smaller version of the problem. Sure, you need to figure out how to condense some of the sub-problems together so you can handle large P without running out of time or memory, but that's a much more straightforward problem.