Here is my solution http://www.codechef.com/viewsolution/5165131 I have used recursion along with memoization and I am still getting time limit exceeded. Are there any mistakes in implementation?
You shouldn’t use recursion in the first place. Its non-linear and time complexity sucks. Check out my code
done with bottom up DP. Cheers !!