(1) For each color, put all the cubes of that color in their own pile. So, get 10 piles, and in each pile all the cubes have the same color.
(2) Arrange these piles in ascending order from left to right on the number of cubes in each pile. So, a color with the fewest cubes is on the left, and a color with the most cubes is on the right.
(3) If the pile on the left has 10 cubes, then pack each pile in its own box, and we are done.
(4) Else take cubes from the pile on the right and put them on the pile on the left until the pile on the left has 10 cubes.
(5) Go to step (2)
This problem and solution generalize immediately to, for positive integers m and n, n colors, n boxes, and (m)(n) cubes.
Or, if we have n factories where each factory produces cubes of just one color and have n warehouses each of which needs m cubes, and the total number of cubes produced is (m)(n), then it is possible to ship the cubes from the factories to the warehouses so that each warehouse gets cubes of at most two colors. So, there is connection with the 'transportation problem'.
That problem is a special case of least cost capacitated network flows which is a linear programming problem with some special properties. In particular if all the capacities are integers and have an initial flow with all integers, then the simplex algorithm will find a least cost solution with integer flows. So, here is a way to integer linear programming for no extra effort. The general case of integer linear programming is in NP-complete. The simple algorithm on such networks is closely related to spanning trees.