Add DP using memoization