Can someone explain Um_nik's elegant approach in an easy 1400 rated DP problem ?

Revision en1, by nitin12384, 2023-01-27 13:37:45

Here's a problem and Um_nik's solution to it.
I was thinking about a lot of things, tried DP etc. and was unable to solve it.
Then I saw this crazily concise solution of Um_nik.
Can someone explain, what's his approach?
Like, I understood what he's doing, but didn't understand why it's working, or I should rather say, how he came to this solution.
Like the idea, or some convincing observation behind this idea.

Tags easy


  Rev. Lang. By When Δ Comment
en1 English nitin12384 2023-01-27 13:37:45 641 Initial revision (published)