Neighburing Enemy

Can you please help me to proceed with this problem ?

Hey @aman2382000
This is a DP ques. Store the frequency of each element in an array with index as value. Then apply DP on it. For each value you have 2 options, DP[i] = max( i*freq[i]+DP[i-2] , DP[i-1] )

If your doubt is resolved please mark it as closed.

Bhaiya it’s not showing green tick even when all my test cases are passed.

Sorry for the issue buddy. I’ll forward your concern to the team and we’ll try to fix it ASAP.
Till then good job on this question and I would request you to move on to other questions. If you still have any other queries you can also mail it at [email protected]

If your doubt is resolved please mark it as closed.

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.

My code gives WA for this when i submit it on codeforces. It is accepted here. Can u pls tell the possible reasons and changes ? CODE : https://codeforces.com/contest/455/submission/77693251

@aman2382000 you can see which test cases it failed for on codeforces itself.

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.