OptimalGrouping DP done