Getting MLE error

Getting memory limit exceeded

Since you are using map, TC to find an index is log(n) and we have to find it in o(1) time, use 2-d array achieve this. Also make all your int to long long int as value of A[i] lies in long long int range.

It is giving TLE when I was using a map, but when I used vector it started giving MLE

you might not be iterating in a right manner on vector, try to use 2-d array, for i & jth index. it will work absolutely fine for it.

Now, I am getting run time error

send me your entire code, i will correct it. Send it using ide.codingblocks.com

Submit this now

what’s the error in this code?

I am using bottom-up dp now, but you sent the link of previous code

the way you were iterating on your 2 d array is wrong, take reference from this

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.