Thank You very much Sir! I got it.
Abra-Kadabra- and we’re done. Have a check for your comment @aryanc403 and tell if any correction is needed.
Your code has complexity of pqM. (p*q for the dp and M for find operation in each recursive call)
Constrains for third task were: p,q < 2000 and M < 3000
So it would even exceed 10^9, hence the TLE.
Also, your code was missing the following condition check:
if(good > p or bad > q) return 0;
Hence, your previous submission were getting RE(SIGSEGV). Since it may happen good ~ p + q = 4000 → that would exceed your array limits.
I incorporated the above mentioned changes in your code & got this code pass 1st subtask.
Hope that helps.
Thanks mate
I bet he will grin like a cat on seeing this xD
XD @both of you
_ /|\ _ @vijju
Yes, the approach is based upon André’s reflection method.
I think almost everything is covered in this editorial - so you can safely skip reading it from there.
Yeah! thanks for pointing out the typo. I have updated the editorial