I am unable to understand the question with the given sample input. Could you please use another sample input to explain the question.
Problem in understanding the problem statement
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, this would help you better understand the problem.
@S18ML0016 Thanks for explaining me the question.
Could you also please explain that how do we approach this problem using the divide and conquer technique