CCC07S5 - DP solution

works on all test cases.