actually O(n^2 * m) algorithm works, i just got accepted using save space trick, instead of O(m*n) memory i used O(2*n) memory, algorithm runs a little faster because of CPU's CASH. my time was 0.989,Adrian Kuegel wrote:I also just found a counterexample for your current greedy algorithm:
4 11 2
9, 10, 2, 11
optimal solution is:
9 2
11
but your greedy will get:
9
2
unfortunately, the O(n^2 * m) dynamic programming algorithm I have is too slow. And the pruning I inserted seems to be wrong.
but i like to know O(m*n*t) algorithm too!:D