My code gives tle

like i said my coode gives tle https://ide.codingblocks.com/s/254966

checkout dynaimic programming to optimise your solution.

Hello @aayushmathur05,

Hey you are required to use DP in this question to pass the test cases.
So, i’ll suggest you to first complete your DP module and then solve this question.

test case 3turns out to be true while others are wrong https://ide.codingblocks.com/s/254966

Hello @sshreya2912,

You may refer to the following link and understand this question first:


If you still face any issue, let me know.
I’ll correct your code.

my logic seems right, is it not? I do understand the question

Hello @sshreya2912,

I have corrected your code:

Hope this would help.

the corected code is giving me WA for all except for one after setting every thing to ll

Hey @sshreya2912,

After setting everything to what?

long long, after setting my datatype to long long

Hey @sshreya2912,

It shouldn’t have been the case.
You must have done some mistakes while making changes.
Please, share your code.

I am getting 20/100 here is my link to code https://ide.codingblocks.com/s/265604

Hey @sshreya2912,

It has nothing to do with the data type you use.
There is a missing statement in the corrected code:

For each iteration of the while loop i.e. for each test case you have to initialize the array to 0 as:
memset(dp,0,sizeof(dp));

Hope, this would help,

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.