Painter problem- code seems to be correct.but test cases are failed

i used the same approach in as in book allocation problem.

Try to take the value of s in your code to be maximum(ar,N), and then try to submit the code.