AtCoder ABC135-D

I’m really having a hard time understanding the solution to this problem, multiple users have posted their solutions and I’ve also read the discussions on codeforces but I’m unable to understand any of that. Please help.

have a look at my submission if it helps.

2 Likes

Like when you read the question and wrote the solution for it … what was your thought process? How did you figure out that it can be solved using DP ? Could you please explain your code more ?