Getting WA for 3rd and 5th test cases!

@sourabhsh55
In the main() function

  1. s should be initialised with 0, or the minimum element of a. Why have you initialised it with a[b-1]?
  2. ans should be initialised with sum rather than INT_MAX

In the func() function

  1. The condition in func()
    image
    should not be used, because number of boards can be more than 3. the number of painters and vice versa. A painter CAN paint more than one board, or no boards at all.
  2. One condition that needs to be added is that,
if (a[i] > mid) {
    return false;
}

this statement needs to be added because if a board length is greater than what a painter is capable of, it cannot be painted at all (because one board cannot be painted by more than 1 painters).
3. return painter <= mid instead of true to ensure the condition.

Here is your fully corrected code that is passing all the cases