Problem 11.1. In a basket, there are 41 apples: 10 green, 13 yellow, and 18 red. Alyona sequentially takes one apple at a time from the basket. If at any point she has pulled out fewer green apples than yellow ones, and fewer yellow ones than red ones, she will stop taking apples from the basket.

(a) (1 point) What is the maximum number of yellow apples Alyona can take from the basket?

(b) (3 points) What is the maximum number of apples Alyona can take from the basket?
Answer: (a) 13 apples. (b) 39 apples.

Solution. (a) Alyona can take all 13 yellow apples from the basket, for example, if the first 13 apples turn out to be yellow. Since at no point do the yellow apples become fewer than the red ones, Alyona can indeed do this.

(b) We will show that Alyona can take all the apples except for two yellow ones. Let her take 10 green apples first, then 18 red ones, and then 11 yellow ones. Note that until the number of yellow apples reaches 11, the condition that there are fewer green apples than yellow ones will not be violated. Thus, Alyona can indeed take 39 apples.

Now we will prove that Alyona cannot take more than 39 apples. Suppose the opposite: Alyona managed to take 40 apples at some point. Before taking the 40th apple, she already had at least 11 yellow apples. She had taken no more than 10 green apples by this point, so the first condition is definitely satisfied. On the other hand, she had taken no more than 13 yellow apples and at least 16 red ones, so the second condition is also definitely satisfied. But then she would not take the 40th apple, a contradiction.