I am a bit confuse about this problem. I am not sure I understand the dp process correctly.
I define the state as dp[i][j], which means the max sums until the i-th position and j pairs. so,
dp[i][j] will update dp[i+m][j+1] (including numbers starting from i+1 to i+1+m)
dp[i+m+1][j+1](including numbers starting from i+2 to i+2+m)
....
But this solution exceed the time limit. I can't find where is the problem. could you please help me. thank you in advance.
here is my solution, link: http://codeforces.me/contest/467/submission/9970270