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

https://mirror.codeforces.com/problemset/problem/1215/B

https://mirror.codeforces.com/contest/1215/submission/60611022

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

History

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