2D Dynamic Programming - Preparation to IOI Part 2