max path sum using dynamic programming