add DP algorithm