Stuck with this dp problem ,passing some tests failing on others

Problem-https://codeforces.com/contest/1461/problem/B#

Solution link-

I got my error it was a silly mistake thanks btw.

Hello @mridulmohanbagri17 is your error resolved now ?

or should i see into it?

Yes it is resolved .Thankyou for your 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.