4. Masha has 1000 beads in 50 different colors, 20 beads of each color. What is the smallest such that for any way of making a necklace from all the beads, one can choose consecutive beads, among which there are beads of 25 different colors?
Problem 934
Official solution
Answer: .
First solution. Let's call a segment of the necklace of length a set of consecutive beads. If the beads in the necklace are arranged in groups of 20 of the same color, then a segment of length 461 cannot contain more than 24 different colors. Therefore, . Consider a segment of the necklace of length 462. Suppose that in this segment, 25 beads of different colors do not appear. Number the beads of the necklace counterclockwise so that the first beads are those of the chosen segment. Let be the number of the first bead of a color that is not present in the segment (say, yellow). We will show that the segment of the necklace from to contains 25 colors. Indeed, the yellow color is present in it. In the remaining part of the segment, the yellow color cannot appear by construction. But there are beads of at least 24 colors in it, since .
Second solution. Let's call a segment of the necklace 462 consecutive beads. We will show that in some segment, there will be 25 different colors. Suppose the opposite. Then in any segment, there are no more than 24 different colors. Consider all possible pairs consisting of a segment of the necklace and some color present in it. In each segment, there are no more than 24 different colors, and the total number of segments of the necklace is 1000. Therefore, the number of pairs does not exceed . Now consider some specific color (say, blue). There are 20 blue beads in total, and between the farthest blue beads and , there are always at least 18 beads (exactly 18 only when all blue beads are consecutive). Thus, there are at least 19 segments containing and not containing . The bead itself is included in 462 segments. Therefore, blue beads are contained in at least 481 segments. These arguments are valid for any color. Therefore, the total number of pairs is at least , which is impossible.