Question link:- https://www.spoj.com/problems/PRATA/
My code link:- https://ide.codingblocks.com/s/378055
I don’t know where am I going wrong.
Question link:- https://www.spoj.com/problems/PRATA/
My code link:- https://ide.codingblocks.com/s/378055
I don’t know where am I going wrong.
hello @div_yanshu07
evrything look fine to me.
probably some implementation issue is there in ur isPossible function , give me some time to debug this.
till then u use this function for is possible.
let say time is T (mid) and cook i cooks x paratha then we can say
a[i] *( 1+ 2 + 3...+x) <=T
a[i] * (x * (x+1))/2 <=T
x*(x+1) <= 2*T/a[i]
x^2 +x - 2*T/[i] <=0
solution of this equation by sridharachary formula
x= (-1 + sqrt(1+8 * T/ a[i] )/ 2
so just go to each cook and compute this x. and add it to ur count.
at the end if count >=p return true otherwise return false.
time_used+a[i]*j<=time?
I tried but giving wrong answer.
check now->
that cook used constraint was creating issue. u dont have to add that constraint becuase it will always be satisfied because i is always < n
Okay. Thankyou!!!
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.