Question from today's Atcoder Yahoo Programming Contest , Problem D.

dynamic-programming

#1

Can anyone help me in solving problem D of Atocder , which is based on some dp approach , How to formulate dp state : many solutions are very short but what they are ?

LINK : https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d

Editorial link : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf