Could anyone please exlain me how to solve this dp problem? Link:https://atcoder.jp/contests/dp/tasks/dp_n Help?
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 | 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 |
| # | User | Contrib. |
|---|---|---|
| 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 |
| 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); ]