Painters problem in binary search


My two test cases are not working, help me out.