uva 590 2D dynamic programming