Variant 11.1.2. In a basket, there are 38 apples: 9 green, 12 yellow, and 17 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) 12 apples. (b) 36 apples.