PROBLEM LINK:Practice Setter: Akil Vohra DIFFICULTY:Easy PREREQUISITES:Observation. PROBLEM:Given the number of jars required by $N$ junior chefs for keeping ingredients which they may take in any order, find out the minimum number of jars required so as to ensure every chef can complete his recipe. It is to be noted that once a chef completes his recipe, he puts back the jars for reuse by other chefs. QUICK EXPLANATION
EXPLANATIONQuick Explanation said it all. We need to think what can be the worst case, where the maximum number of jars are used and yet chefs are unable to complete their dishes. It happens when all chefs are one short of their jar requirement. Since once any chef completes his dish, the jars are available for reuse. So, the worst case shall not have any chef's dish already completed. So, now, we need to find the maximum number of jars such that each chef's dish isn't ready, but using a maximum number of jars. That's it. For chef requiring $x$ jars, we can block $x1$ jars. So, the Maximum number of jars such that no dish is complete is $\sum (x1)$. Now, to break this deadlock, we need one more jar. Hence, the required number of jars is $\sum x  N+1$. Time ComplexityTime complexity is $O(N)$ per test case. AUTHOR'S AND TESTER'S SOLUTIONS:Setter's solution Feel free to Share your approach, If it differs. Suggestions are always welcomed. :) asked 13 Feb, 23:59

This problem was a test of english understanding skills rather than coding answered 20 Feb, 09:25

Hello Sir,any order means any one of the permutation of the given N junior Chefs.please let me know if my understanding is wrong
link
This answer is marked "community wiki".
answered 14 Feb, 18:04

I lovedddd this question a lot!!! I cannot believe this....a few days before my operating systems sir teach me deadlock and oh great god i applied it to the problem and got an 100% points!!!! the editorial is as usual lovely <3 and this line " Now, to break this deadlock, we need one more jar." is pure love <3 :D thank you for your wonderful editorials @taran_1407 !! also, can you please tell when guessrt editorial will come? I try so hard but cannot do it :( answered 14 Feb, 23:19

Scheduler will not give less resources when there are enough for one process demand Regards Samuel answered 15 Feb, 17:01

Please confirm my understanding : The distribution of jars is random, like, we can't guarantee that who will get how much, so we choose a minimum number such that whatsoever the distribution, the session ends successfully. The max logic is faulty as it will only work if chefs cooperate among themselves, or the maxm demanding chef can obtain all those jars for himself which is not guaranteed. answered 24 Feb, 23:45
