Tweaked DP implementation - Accepted

Signed-off-by: Vineel Kumar Reddy Kovvuri <vineelkumarreddy@gmail.com>
Nice use of segment trees again

Signed-off-by: Vineel Kumar Reddy Kovvuri <vineelkumarreddy@gmail.com>