I was trying to do this question when I read the comments I came to know that the problem is about Convex Hull technique of Dp optimisation.Then I read this article on Dp optimisation convex Hull techniqueHere.Can anybody help me in understanding the code.