My code is - https://ide.codingblocks.com/s/323427
Prata code not working
@sukritbansal01
There were a few errors in your code.
- Set j = ((p*(p + 1))/2)*(max time taken by a chef)
- The max time can be found by sorting the array and taking the element lying at the last index.
- This is because we wish to set the upper bound to the maximum which might be taken.
- Use long long instead of int
- Also in the add function, return (i - 1) instead of i because it is the ith one which cannot be cooked because of time constraints. This is the reason (i - 1) should be the answer.
- Do not use a loop in the add function. Try solving the question of numbers of paranthas cooked in the given time limit using quadratic equations as your method might lead to TLE.
If my solution was able to answer your doubts, please mark the 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.