Tilling problem 2

why i am getting time limit exceeded

my code
https://ide.codingblocks.com/s/60003

Please try with memoization in your code. It means you can store the ans of a subproblem the first time you solve it and then use the same ans when you encounter that subproblem instead of solving it again.
This will optimize time-complexity of your code.