Hello, I am unable to figure out how I can formulate DP for this problem (https://codeforces.me/problemset/problem/467/C). Thank you!
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | jiangly | 3670 |
| 3 | Kevin114514 | 3657 |
| 4 | maroonrk | 3355 |
| 5 | Um_nik | 3353 |
| 6 | squareOf105 | 3346 |
| 7 | tourist | 3343 |
| 8 | strapple | 3324 |
| 9 | heuristica | 3322 |
| 10 | jiangbowen | 3291 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | AmShZ | 143 |
| 5 | Um_nik | 141 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | BledDest | 134 |
| 9 | maroonrk | 133 |
| 10 | qwexd | 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!
| Название |
|---|



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!