Also checked out the Hint video but couldn't figure why it is giving wrong answer

@aryan_007
please refer to this code https://ide.codingblocks.com/s/256502

Sir , i couldn’t understand why every TA just send their code , If i only wanted to see the code then i would have opened Editorial by now !! I spend 8,000 rupees extra not to see your code but to know where i am going wrong . Although it is a bit Harsh but i am frustated by reply of you guys , every next TA just hand me over their code and say your approach is wrong but could never tell where i am going wrong . So, For this i gave 8,000 rupees extra ???

@aryan_007
your code seems to be correct, i thought you can figure it out by looking the code, ok no issues forget the above code.
One thing which i think missing is while calculating the max_ans, you are starting from i=k+1, which should be i=k.
can you once explain what exactly your backward DP array is representing, it may be an issue with it.

1 Like

@aryan_007
see for this input
5 2
-1 -2 -2 -1 -1

your code is giving -3 but the correct answer will be -1.
Try submitting after doing the correct for max_ans by starting it from i=k.

1 Like

Yes sir , you are correct it should give -1 but mine is -3 but by some how my previous code got accepted by just removing that ifndef online judge part , I guess the test case in it are pretty weak , do let them know about your test case , your test case should also be added in it !!

Thank you sir !!

Btw are you from IT branch 3rd year ??

1 Like

yes Aryan i am from 3rd IT.

Mark this doubt as resolved if its clear now.

Yes sir , It is solved !! Marking as resolved Thanks!!

1 Like