array partition without reordering, DP solution added