DP algorithm added