At ACM ICPC SEERC 2009 was this problem:
Problem E.
I need a hint to solve it. My instinct tells me that some sort of dynamic programming would do. But I can't figure it out.
Problem E.
I need a hint to solve it. My instinct tells me that some sort of dynamic programming would do. But I can't figure it out.
However, the time limit is tough and some optimizations are needed.
Here is the code that got accepted on this online judge.