WA in painters partition

getting 3 WA in this code https://ide.codingblocks.com/s/42021
whats wrong in this
ques link https://hack.codingblocks.com/contests/c/522/716

sufficient_time is computing wrong answer.
If threshold time = 5
given time to paint the boards= 1 1 1
and available painter=1
your sufficient time is saying that u will need 2 painter

so here is the updated code of sufficient time

bool sufficientime(ll thresh,ll availpainters)
{
ll paintersreq=0,i=0,timetaken=0;
while(i<n)
{ timetaken=0;
paintersreq++;
while((timetaken + arr[i])<=thresh)
{
timetaken+=arr[i];
i++;
}

}
if(availpainters /* 2 */ < paintersreq /* 3 */)
 return false;
else
return true;

}

Like kar dio…warna class main jabardasti karwaaunga

1 Like