how to solve JACKJACK from Tessellathon

help
dynamic-programming
tess2018

#1

How is solve this question

From what i have seen people are applying but how?