Why is my code giving WA on multiple test cases?

I tried to solve the problem “Painter’s Partition Problem” on hackerblocks but i am getting WA on multiple test cases. I have made a function isPossible which checks if ‘k’ painters can paint the entire board in ‘m’ time.

Question Link: https://hack.codingblocks.com/app/practice/1/1057/problem

My code: https://ide.codingblocks.com/s/260260

hello @HemantKumar
in place of this if->
image

use while loop->
image