Editorial for Back From Summer '17 P2: Crayola Lightsaber
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Let be the color with the greatest number of markers, thus, there are markers remaining.
First, let us prove that it is always possible to fit in the markers that are not of the color .
While are still markers that are not of the color , first append the sword with a marker of color . Next, take one of each color of the remaining colors and append them to the stick. Since all the colors are different, there will never 2 markers with the same color adjacent to each.
Since no color has more markers than , there will always be a marker of color available, and we are able to use all markers.
To fit in the remaining markers colored , we must take previously placed markers to "pad" them.
It is easy to convince yourself that the maximum number of markers you can put down with "padding" markers is using a sequence like ABABABA
.
Therefore, we can place at most , giving us the solution.
Comments