Let $A$ be a set of positive integers with the following properties:

(a) If $n$ is an element of $A$ then $n \leqslant 2018$.

(b) If $S$ is a subset of $A$ with $|S|=3$ then there are two elements $n, m$ of $S$ with $|n-m| \geqslant \sqrt{n}+\sqrt{m}$.

What is the maximum number of elements that $A$ can have?
Assuming \( n > m \) we have

\[
\begin{aligned}
|n-m| \geqslant \sqrt{n}+\sqrt{m} & \Leftrightarrow (\sqrt{n}-\sqrt{m})(\sqrt{n}+\sqrt{m}) \geqslant \sqrt{n}+\sqrt{m} \\
& \Leftrightarrow \sqrt{n} \geqslant \sqrt{m}+1 .
\end{aligned}
\]

Let \( A_{k} = \left\{ k^2, k^2 + 1, \ldots, (k+1)^2 - 1 \right\} \). Note that each \( A_{k} \) can contain at most two elements since if \( n, m \in A_{k} \) with \( n > m \) then

\[
\sqrt{n} - \sqrt{m} \leqslant \sqrt{(k+1)^2 - 1} - \sqrt{k^2} < (k+1) - k = 1
\]

In particular, since \( S \subseteq A_{1} \cup \cdots \cup A_{44} \), we have \( |S| \leqslant 2 \cdot 44 = 88 \).

On the other hand, we claim that \( A = \left\{ m^2 : 1 \leqslant m \leqslant 44 \right\} \cup \left\{ m^2 + m : 1 \leqslant m \leqslant 44 \right\} \) satisfies the properties and has \( |A| = 88 \). We check property (b) as everything else is trivial.

So let \( r, s, t \) be three elements of \( A \) and assume \( r < s < t \). There are two cases for \( r \).

(i) If we have that \( r = m^2 \), then \( t \geqslant (m+1)^2 \) and so \( \sqrt{t} - \sqrt{r} \geq 1 \) verifying (b).

(ii) If we have that \( r = m^2 + m \), then \( t \geqslant (m+1)^2 + (m+1) \) and

\[
\begin{aligned}
\sqrt{t} \geqslant \sqrt{r} + 1 & \Leftrightarrow \sqrt{(m+1)^2 + (m+1)} \geqslant \sqrt{m^2 + m} + 1 \\
& \Leftrightarrow m^2 + 3m + 2 \geqslant m^2 + m + 1 + 2\sqrt{m^2 + m} \\
& \Leftrightarrow 2m + 1 \geqslant 2\sqrt{m^2 + m} \\
& \Leftrightarrow 4m^2 + 4m + 1 \geqslant 4m^2 + 4m .
\end{aligned}
\]

So property (b) holds in this case as well.