DELISH dp problem

can anyone explain me the approach of this problem i am not getting its editorial.