Help needed in Circular merging problem.[dp]

please help me where am i doing wrong?

solution link: https://www.codechef.com/viewsolution/33566616

problem link: circular merging