Solve this problem and write an editorial

2D dp
Plz some help me out I am unable to solve it.

//