I don’t understand this task at all.
I mean I understand the solution, I just don’t understand why that solution is the way it is.
Like, what dictates how many jars that the chefs need ?
I just don’t get it and I’m really, really frustrated that I don’t get it.
“The junior chefs take some jars; let’s denote the number of jars taken by the i-th chef by ai. Any distribution of jars such that 0≤ai for each valid i and ∑Ni=1ai=J is possible.
At any time, if ai<Ai for each chef i that has not prepared their dish yet, the cooking session is a failure.
Otherwise, one of the chefs who have at least as many jars as the number of required ingredients prepares their dish and returns their jars to the kitchen.
Whenever some jars are returned to the kitchen, they are immediately taken by some chefs that have not prepared their dishes yet (possibly all the jars by one chef).
This process continues with chefs taking jars, cooking their dishes and returning jars, until no chef can cook their dish anymore or all chefs have cooked their dishes.”
I don’t get this part at all ,in any single possible way, how am I supposed to conclude how many jars are the minimum ??
The test cases don’t provide that, from a blind perspective, you need as many jars as the guy that requires the most jars, I don’t get how, let’s say 10 chefs need 28 jars, but 19 is somehow the solution, when if we follow the logic of “Chefs will return their jars when they finish” then the answer should be the amount of jars that the most demanding chef needs, for example if my most demanding chef needs 8 jars, then the answer should be 8, but it’s not… Why ?
If all the chefs return their jars, then if 10 chefs needs jars in this order : 2,4,6,8,2,2,1,1,1,1
Then the answer through some stupid logic should be 8, since all of the chefs will just return the jars when they finish, and the most demanding chef needs 8 of them, but the answer here is 19. Why would any chef need 19 jars ?
Also your solution links don’t work so I can’t even solve what’s wrong with my problem.