Help with approach

code: https://ide.codingblocks.com/s/434465

prob: https://atcoder.jp/contests/abc153/tasks/abc153_e

not showing any output (I know it has to be optimized for subimission).

hello @raghav007

make ur base case h<=0 and then try

also check input format,
u have input in this format
ai bi
a2 b2


it is giving the wrong answer

@raghav007
check now->

why is it giving tle after memoization

u r never using ur memoised array.
initilaise ur dp array with -1.

and iside ur function.
check if(dp[h]!=-1) then return dp[h];

oh sorry,

it is not working for this test case is it because of recursion?

@raghav007

it is because of ur memoisation inside base case.

u r memoising negative h thats why it is givng seg fault

thanks a lot now it is accepted, you are able to help much more than others

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.