5. In the box, there are 100 cubes, all of whose sides are painted red, green, or yellow. Among them, 75 cubes have at least one red side, 80 cubes have at least one green side, and 85 cubes have at least one yellow side. What is the smallest possible number of cubes that have sides of all three colors?
## Solution.

Let:

$a=$ the number of cubes whose all sides are red

$b=$ the number of cubes whose all sides are green

$c=$ the number of cubes whose all sides are yellow

$d=$ the number of cubes that have only red and green sides

$e=$ the number of cubes that have only red and yellow sides

$f=$ the number of cubes that have only green and yellow sides

$x=$ the number of cubes that have sides of all colors

These notations can be more clearly represented by a Venn diagram.

![](https://cdn.mathpix.com/cropped/2024_05_30_b67770dbc376921a4b0eg-5.jpg?height=405&width=638&top_left_y=1266&top_left_x=581)

yellow side

From the problem statement, we can read the system of equations:
$$
\begin{aligned}
x+a+d+e & =75 \\
x+b+d+f & =80 \\
x+c+e+f & =85 \\
x+a+b+c+d+e+f & =100
\end{aligned}
$$

Sum the first three equations and subtract twice the fourth equation. We get:

$$
x-(a+b+c)=40
$$

from which it is clear that $x \geq 40$.

The smallest possible number of cubes that have sides of all three colors is $x=40$ and it is achieved when

$$
a=b=c=0, \quad d=15, \quad e=20, \quad f=25
$$