Google interview question

a very difficult dynamic programming problem