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: https://www.youtube.com/watch?v=jxVzUg7oSP8

1 Like

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

https://www.hackerearth.com/practice/algorithms/dynamic-programming/introduction-to-dynamic-programming-1/practice-problems/algorithm/sonya-clears-the-array-icpc-2/

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: https://www.codechef.com/viewsolution/25350258
Still WA.

There is another INT_MAX inside the f function.

1 Like

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