I tried writing the code but its not working
Find out minutes to cook given no. of prata
didnt understand line 14 and 43
in line 14, u are going to add r in ur sum, so u need to check that after addition sum dont exceed mid that is why sum+r <= mid.
in line 15. the cook with maximum cooking time (mx) will cook paratha in p paratha in mx * p*(p+1)/2 time
why you did n*mx in line 43
i am already updating sum +=r and it is getting checked<=mid
…
here i explained na->
ur n is nothing but p*(p+1)/2
u are first checking sum <=mid
and then adding r to it.
which is wrong.
u shuld first see whether after perfoming addition it will remain <= mid or not.
and then act accordingly
i understood. thank you
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.