Could anyone please exlain me how to solve this dp problem? Link:https://atcoder.jp/contests/dp/tasks/dp_n Help?
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3408 |
| 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 | 135 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
Could anyone please exlain me how to solve this dp problem? Link:https://atcoder.jp/contests/dp/tasks/dp_n Help?
| Name |
|---|



Check this out... https://www.codechef.com/JULY19B/problems/CIRMERGE/
It also has a nice editorial.
Its easier to understand the recurrence relation from a solution done made with recursion (and memoisation), so here you go — https://atcoder.jp/contests/dp/submissions/15834404
this video by Errichto helped me a lot while solving the dp atcoder contest : https://www.youtube.com/watch?v=FAQxdm0bTaw&t=8731s
Is there anything I am missing? If someone can help ?
Link : My solution
Update to
cost=1e18;and it works.Am i missing something in this solution: https://atcoder.jp/contests/dp/submissions/22675988
lli i,a, b = sum[endi]-sum[start-1],c=INT_MAX;ccan be larger thanINT_MAXIf you want to learn the concept behind this problem then go through Matrix chain multiplication DP, it is a very famous DP problem and has clear explanations(you can check Cormen or any online articles). This N-slimes problem is very similar to that but instead of multiplication, we do addition.
DP say the coset, marge to some grup (l to r ) slimes into one slime . and the final slimes size is sum of all slimes size ," whis make to marge (l to r ) slimes .
when l == r , the cose 0, becouse one slime . now make a for loop for( i = l; i<r; i++) this make make to deferent grup l to i and i+1 to r. find the cost to grup [l,i] and [i+1,r] and add the final slimes size [l,i] -> one slime whis size sum of all slime l to i. solv(): if l == r return 0; for( l to r-1 ) min[ sum l to i( final slime size l to i grup ) + sum i+1 to r + solv(l,i)[ cost to make one slime frome [l ,i ] grup ] + solv( i+1, r); ]