Painter's Problem - Binary search

What’s wrong in this code?

Your implementation for canTheyPaint is incorrect, remember that each painter paints continuous segment of board and each board can be painted by only one painter!