Prata spoj function logic

Hey i am unable to build the logic for the function that has to be created. How can i find out time for chef’s with different rankings

hello @soumyabhardwaj75

u need to check whether all available cook can finish desired number of prata P in given time T or not.

so in ur function , go to each cook and calculate how many prata he can cook in time T . and all the prata count .

if all the prata count >=p then return true otherwise return false

bool isPossible(int p, int l, int r[], int curr_min){

   int  silver=0 ; //total pratas count

   for (int i = 0; i < l; i++) {

       int x = 1;  

       while ( (x * (x + 1)*r[i]) <= 2*curr_min )  //Here pratas are made in arr[i] ,2arr[i] ,3arr[i] .... summation = x*(x+1)/2*arr[i] so we are doing that here to find max x which satisfy that

           x++;

       x--;

       silver += x ; //adding pratas by current chef to total answer

   }

   return silver>=p ;  //if total pratas > required pratas 

}

Hey i am not getting this function can you please share the whole code

https://ide.geeksforgeeks.org/wfOcwOoOWi hey i have used this code for reference . . I didnt get this line 10 and 11

in line 10 , we are simply assigning time that ith cook takes to cook its first parath in next_time variable.

in line 11 we are checking whether the cook can cook one more paratha within assigned time or not.
if yes then we enter the loop update next cooking time and increase paratha count by 1

no no i mean what is this t +next_time what is t ?

t is the cook right ?

what is the logic behind line no 15 of the code that i had shared

t is time that cook has already spent in cooking paratha.
after cooking one more paratha the total time will be t+next_time

cooking time increase by cook[i] after every paratha, we are doing the same in line 15.

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.