Test case 0 and test case 2 problem in painter partition problem

I am able to pass all the test cases excpet 0 and 2 . Please can you give me the example where my code would give false output.

@rahul.aggarwal000005
Consider this testcase
2
3
5 1 1
Your code is giving “2” as output but ans can’t be 2 . Answer should be “5”. I check your code and find a mistake in line 29. s should be maximum element of the array not the element at last index (here input array is not sorted). Simply write for(int i=0;i<n;i++){ s=max(s,a[i]); } after line no. 29. All testcase will pass.