How to solve the DP problem in ECNA 2017 Problem G: Ingestion Question?