A 2D DP Problem - Collecting apples

Please someone help me with the approach to this 2D DP Problem,

link - Collecting Apples | Practice Problems

Thanks!!