Hello, I am unable to figure out how I can formulate DP for this problem (https://codeforces.me/problemset/problem/467/C). Thank you!
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
Hello, I am unable to figure out how I can formulate DP for this problem (https://codeforces.me/problemset/problem/467/C). Thank you!
| Name |
|---|



You can think it like this:
If you are at index i and you need x pairs, you have two options: 1) take the sum of the next m elements, move to index i+m and now look for x-1 pairs 2) move to index i+1 and look for x pairs
That can be written as a dp with two states: the index in the array and the number of pairs you need
dp[i][k] = max(dp[i+1][k], dp[i+m][k-1] + sum(A[i], A[i+1], ... , A[i+m-1]) )
Okay, got it now... got confused with ranges(thought they could collide).. thanks for the help!