CodeChef interview question

Dynamic programming related of hard level