Time limit exceeded while using recursion

https://ide.codingblocks.com/s/51709
https://hack.codingblocks.com/contests/c/537/1045
How to optimize this??

the constarints are large so you can’t use brute recusion, instead of calculating the same problem again and again or overlapping problems you can store it in a Dp array and use to compute the answer of bigger problem.
Do it by bottom-up approach. If you are not able to get it let me know.
Cheers :slight_smile: