Painter Partition problem wrong answer at several test cases

this is my solution for the Painter partition problem. I couldn’t understand where am I going wrong with it getting the wrong answer at test case 1, 3, 4, 5. I thought it may be because of limit for xi<= 10^8 but it should not result in overflow as N<= 10, what’s the issue then?
Please help.

Hello Abhishek ! your boolean function in this code is wrong you should add some other conditions too such as you have to check if(pages) then k++, and if(k>point) return false . this condition should be checked after the end of for loop . Okay find your mdified code here .
https://ide.codingblocks.com/#/s/14190
Fine now ??

Thanks for the reply and your solution. boolean function is fine, the real issue was I was taking input n first instead of k, my bad :man_facepalming:

dont sort it :stuck_out_tongue:

Why is the start of search space taken as maximum element of array?