Painter Problem

How to check that is it possible to paint N boards of length a[N] in mid time or not

how to check write is possible function

Hello @mohitsharmakosi2001 in this question you will check by applying binary search on time. I.e the maximum time possible is if we have only 1 painter so that’s why we have to add the dimension of each box and the minimum time possible is when we have number of painter equal to the nunber of boards.
So you have decided your range now you will make check by asking the boards to each painter in the manner as they are taken in input .
You will assign boards to painter and when you will find the giving one more board to the same painter will not come in that much time say mid then you will call another painter from that point.
You will do the same

And if at any point the number painter assing increases then the total number of painter then you will return back with false saying that you need to increse some time.

plz write is possible function in the form of code, i try a lot but stucking in its code

@mohitsharmakosi2001 check this:

https://ide.codingblocks.com/s/448237 help me to find out my mistake

@mohitsharmakosi2001 check now:


you cannot sort. you have to apply binary search on time.

https://ide.codingblocks.com/s/448321 not passing all the test cases why?

@mohitsharmakosi2001 use long long int as a data type:

thank you so much for help me out of this problem

@mohitsharmakosi2001 Your welcome!
if you feel your query is cleared you can mark this doubt as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.