5. (30 points) In the royal dining hall, there are three tables, and three identical pies are served. For lunch, the king invited six princes to his table. At the second table, one can seat from 12 to 18 courtiers, and at the third table, from 10 to 20 knights. Each pie is cut into equal pieces according to the number of people sitting at the table. There is a rule at the court - the lunch of a knight together with the lunch of a courtier equals the lunch of the king. Determine the maximum possible number of knights the king can invite to lunch on this day. How many courtiers will sit at their table in this case?
Answer: Both guests and courtiers will be 14 people on that day.

First solution: Let the number of courtiers at the table be $a$, and the number of knights be $-b$, then the dining rule can be written as $\frac{1}{a} + \frac{1}{b} = \frac{1}{7} \Leftrightarrow \frac{1}{b} = \frac{1}{7} - \frac{1}{a}$. Maximizing the value of $b$ is equivalent to minimizing the value of $\frac{1}{b}$, which, from the dining rule, is equivalent to maximizing the value of $\frac{1}{a}$, which is equivalent to minimizing the value of $a$. Therefore, the options should be tried starting with the minimum possible number of courtiers.

$$
\begin{aligned}
& a=12 \Rightarrow b=\frac{7 a}{a-7}=\frac{7 \cdot 12}{5} \notin \mathbb{N} \\
& a=13 \Rightarrow b=\frac{7 a}{a-7}=\frac{7 \cdot 13}{6} \notin \mathbb{N} \\
& a=14 \Rightarrow b=\frac{7 a}{a-7}=\frac{7 \cdot 14}{7}=14
\end{aligned}
$$

Second solution: Let the number of courtiers at the table be $a$, and the number of knights be $-b$, then the dining rule can be written as $\frac{1}{a} + \frac{1}{b} = \frac{1}{7} \Leftrightarrow 7(a+b) = ab$. Thus, the value of $ab$ must be divisible by 7, i.e., one of the numbers $a$ and $b$ must be divisible by 7. If the number of knights is divisible by 7, then it is 14, as among the numbers from 10 to 20, only 14 is divisible by 7. If the number of courtiers is divisible by 7, then it is also 14, as it lies in the range from 12 to 18. Thus, in any case, one of the numbers $a$ and $b$ is 14, and then the other is also 14.