Circular merge Help needed

Been stuck on this for a long time. Can’t figure out whats wrong:

https://www.codechef.com/viewsolution/25350090

My approach:
image
(By bhagirathi08)
Reference: Circular Merging Codechef Long using Matrix Chain Multiplication Dynamic Programming - YouTube

1 Like

This is how I solved the problem.
I solved this 2-months ago while practicing dp:-

Programming tutorials, Coding problems, and Practice questions

Now, using its concepts CIMERGE can be solved. :slight_smile:

2 Likes

Thanks! I’ll try this…
But I really suck at dp, always end up looking at the editorial… any tips? How do you approach dp?

1 Like

You just have to change INT_MAX to some large value. INT_MAX has value of 2147483647 but the larger testcases may exceed this.

1 Like

Tried it: CodeChef: Practical coding for everyone
Still WA.

There is another INT_MAX inside the f function.

1 Like

THANKS!!! It Worked! :raised_hands::raised_hands::raised_hands: