Problem 8.3. In a row, there are 127 balls, each of which is either red, green, or blue. It is known that

- there is at least one red, at least one green, and at least one blue ball;
- to the left of each blue ball, there is a red ball;
- to the right of each green ball, there is a red ball.

(a) (1 point) What is the maximum number of red balls that can lie in the row?

(b) (3 points) What is the minimum number of red balls that can lie in the row?
# Answer:

(a) (1 point) 125.

(b) (3 points) 43.

Solution. (a) Among 127 balls, there is at least 1 green and at least 1 blue, so there are no more than 125 red balls. Note also that there can be exactly 125 if the leftmost ball is blue, the rightmost ball is green, and all 125 balls between them are red.

(b) Suppose there are 3 consecutive balls, none of which are red. If the middle ball among them is blue, then to the left of it lies a non-red ball, and if the middle ball is green, then to the right of it lies a non-red ball. This is a contradiction, so among any 3 consecutive balls, there is at least 1 red ball.

Suppose among the two leftmost balls, there is no red ball. If the leftmost ball among them is green, then to the left of it there is no red ball, and if the leftmost ball is blue, then to the right of it there is a non-red ball. This is a contradiction, so among the two leftmost balls, there is at least 1 red ball. Similarly, among the two rightmost balls, there is at least 1 red ball.

All balls, except for the two leftmost and two rightmost, can be divided into \(\frac{127-4}{3}=41\) groups of three consecutive balls. Therefore, the total number of red balls is no less than \(41+1+1=43\). There can be exactly 43 red balls, for example, like this: RBRGRBRGR...RBRGR.

![](https://cdn.mathpix.com/cropped/2024_05_06_1281ceb10571c66f6e2bg-03.jpg?height=62&width=684&top_left_y=1814&top_left_x=385)