i am not able to understand the output. please help me out with few examples.
Painter question
@ankit152 hey ankit
K : number of painters
conditions:
Each painter takes 1 unit of time to paint 1 unit of board.
A board can only be painted by 1 painter at maximum. This indicates that 2 or more painters cannot paint the same board
N: number of boards to be painted
INPUTS:
3
5
1 2 3 4 5
OUTPUT:
5
Explanation :
Initially, there three painters available.
so, the first is assigned the board with maximum unit of size i.e. 5 in this case (it will take 5 units of time)
the second painter is assigned to paint second max. sized board i.e. 4 unit sized board (4 unit of time)
the third, which is the last painter is given 3 unit sized board to paint.(he will take 3 units of time)
After 3 unit of time:
the third painter is free.
so, now he is assigned the 2 unit sized board to paint. (it will 2 unit of time)
so, total unit of time for which the third painter was busy painting(till now)=3+2=5;
After 4 unit of time:
the second painter is free.
so, now he is assigned the 1 unit sized board to paint. (it will 1 unit of time)
so, total unit of time for which the second painter was busy painting(till now)=4+1=5;
After 5 unit of time:
All three painters are free. But, there is no board left to paint.
so, minimum time required to paint all boards are 5 unit
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.