https://codeforces.com/problemset/problem/1327/E

https://codeforces.com/problemset/problem/1327/E

Can anyone explain me the approach to solve this problem? I am unable to understand the codeforces editorial.

It’s not a dp.

Thanks a lot :smiley: . You made my day @everule1