Dynamic Programming Solution CHN07

Problem link

Editorial
Please explain DP solution of this problem.

Please.