I have a set of $N$ ordered objects with respective known sizes. I need to group them into $M$ groups subject to the following constraints:
- Each group must have at least $1$ object.
- Ordering of items should not be altered, that means if the $K^\text{th}$ item goes to group $X$, then the subsequent $K+1, K+2,\ldots$ will go to group $X$ or later only.
- The sum of sizes of items in each group should have least possible deviation with respect to other groups.