like i said my coode gives tle https://ide.codingblocks.com/s/254966
My code gives tle
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.
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
the corected code is giving me WA for all except for one after setting every thing to ll
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.
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.