DIVIDE_GROUP - Editorial

I an also stuck at this point. Please explain anyone.

Imagine a 2D array with K rows and x columns. Each column represents a group.

Now start filling this array from top to bottom and left to right.
That is, first take the \min(x, A_1) candies and place them in the topmost row, from left to right. Since the number of columns is x, you will not go to the second row. Continue from the next cell but now fill in the \min(x, A_2) candies. And so on.

Since there are at most x of each type of candy, you will never add more than one candy of the same type to the same column. Thus, you fill up the whole array, satisfying the constraints.


Nice visualization. Thanks!!