Two test case shows wa
in the code the problem is in ispossible() function
but i think you didn’t understand the problem and its soluiton
here i am explaining the Problem and its solution
Problem:
You have to find the min time require to paint all boards
Solution
min time to paint the board = time taken by that painter who is painting max no of boards
boards[] = {12, 34, 67, 90}
No of painters = 2
There are 2 number of paiters. boards can be distributed in following fashion :
- [12] and [34, 67, 90]
Max number of boards is allocated to painter
2 with 34 + 67 + 90 = 191 boards
we can say that the time require by 2nd painter is the total time
because in the same time painter 1 can finished his task - [12, 34] and [67, 90]
Max number of boards is allocated to painter
2 with 67 + 90 = 157 boards - [12, 34, 67] and [90]
Max number of boards is allocated to painter
1 with 12 + 34 + 67 = 113 boards
from the above distribution we can say that min time is taken in 3rd case
so first we have to minimize the max no of boards assigned to 1 painter
after that if we get the max no of board painted by 1 painter(lets say painter px will paint these boards)
then time requried to paint these board will be the total time
because when px paint these boards meanwhile (on the same time) other painters also paint the boards assingn to them
and to find the max no of boards assigned to painter(minimized) we can use binary search
look at reference Code
Reference Code
if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with
and don’t forgot to mark 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.
I have move the rat in all four direction. But in the same board I have used 1 for visited X for blocked and 0 for open and not visited. The rat goes checks if its open and not visited and moves further otherwise return false. If for a particular block it cant go anywhere we simply return false before backtracking but still it shows wa on few test cases.
for new doubts you have to post it as a new doubt
i have solved your “Painter Problem” doubt and after your no response
i mark it as resolved from my self
so please post this doubt as new one