Example 5 In space, there are 2019 points, where no four points are coplanar. Divide them into 30 groups with different numbers of points. For any three different groups, take one point from each as the vertex to form a triangle. How should the points be divided to maximize the number of such triangles? 
(Adapted from the 1989 China Mathematical Olympiad)
When the 2019 known points are divided into 30 groups with the number of points being $n_{1}, n_{2}, \cdots, n_{30}$, the number of triangles with vertices in three different groups is
$$
S=\sum_{1 \leqslant i < j < k \leqslant 30} n_{i} n_{j} n_{k}.
$$
If there exists $1 \leqslant i < j \leqslant 29$ such that $n_{i+1} - n_{i} \geqslant 3$ and $n_{j+1} - n_{j} \geqslant 3$, then by (2), we know that when $n_{1}^{\prime} 、 n_{2}^{\prime}$ replace $n_{1} 、 n_{2}$ respectively, $S$ increases. Contradiction.

The $i$ for which $n_{i+1} - n_{i} = 2$ is at most one. If there exist $i 、 j$ $(1 \leqslant i < j \leqslant 29)$ such that
$$
n_{i+1} - n_{i} = n_{j+1} - n_{j} = 2,
$$
then when $n_{i}^{\prime} = n_{i} + 1, n_{j+1}^{\prime} = n_{j+1} - 1$ replace $n_{i} 、 n_{j+1}$ respectively, $S$ increases. Contradiction.

The $i$ for which $n_{i+1} - n_{i} = 2$ is exactly one. If the number of points in the 30 groups are exactly 30 consecutive natural numbers, then we can assume they are $k-14, k-13, \cdots, k+15$. Thus,
$$
\begin{array}{l}
2019 = (k-14) + (k-13) + \cdots + (k+15) \\
= 30k + 15.
\end{array}
$$
Taking both sides modulo 5, we get
$$
4 \equiv 0(\bmod 5),
$$
Contradiction.
Therefore, there is exactly one $i$ for which $n_{i+1} - n_{i} = 2$ holds.
$$
\begin{array}{l}
\text{Let } n_{j} = m + j - 1 (j = 1, 2, \cdots, i), \\
n_{j} = m + j (j = i + 1, i + 2, \cdots, 30). \\
\text{Then } \sum_{j=1}^{i} (m + j - 1) + \sum_{j=i+1}^{30} (m + j) = 2019, \\
30m - i = 1554 (1 \leqslant i \leqslant 29).
\end{array}
$$
From this, $m = 52, i = 6$.
Therefore, the number of points in the 30 groups that maximize $S$ are
$52, 53, \cdots, 57, 59, 60, \cdots, 82$.