3.40 A red pencil costs 27 kopecks, a blue one - 23 kopecks. No more than 9 rubles 40 kopecks can be spent on purchasing pencils. It is necessary to purchase the maximum possible total number of red and blue pencils. At the same time, the number of red pencils should be as few as possible, but the number of blue pencils should not differ from the number of red pencils by more than 10. How many red and how many blue pencils should be purchased under the given conditions
3.40 Let $x$ red and $y$ blue pencils be bought. According to the conditions, $27 x+23 y \leqslant 940$ and $y-x \leqslant 10$. Let's construct the lines

![](https://cdn.mathpix.com/cropped/2024_05_21_1e3d8d2f6605ac23e2a5g-108.jpg?height=597&width=625&top_left_y=113&top_left_x=287)

\[
\begin{aligned}
& 27 x+23 y=940 \\
& y-x=10
\end{aligned}
\]

From Fig. 3.8, it is clear that these lines intersect at point $A$, the coordinates of which satisfy equations (1) and (2), and at this point, the maximum possible sum $x+y$ is achieved. Solving the system (1), (2) and considering that the numbers $x$ and $y$ are natural, we get $x=14, y=24$.

Answer: 14 red and 24 blue pencils.