can someone provide editorial for this question?

I am a beginner and need some help.

PROC18C

See my discussion of my approach to this question here https://discuss.codechef.com/questions/133867/editorials-of-procon-2018?page=1#133873

@joffan can u please elaborate the approach i cannot understand the DP Soln (I read yours) i am a newbie in DPs please help thank you :smiley: