Painter's partition problem:test cases

here is my solution:
http://ide.codingblocks.com/#/s/21353
can anyone tell me whats wrong with the code?

Your logic for painter’s partition is not correct. In painter’s partition, you are not allowed to sort the array as a continuous segment is allotted to a painter.

Here is an useful link for painter’s partition problem: