5. Given $n$ points $A_{1}, A_{2}, \cdots, A_{n}(n \geqslant 3)$ in the plane, no three of which are collinear. By selecting $k$ pairs of points, determine $k$ lines (i.e., draw a line through each pair of the $k$ pairs of points), such that these $k$ lines do not form a triangle with all three vertices being given points. Find the maximum value of $k$.
(1996, Shanghai High School Mathematics Competition)
(提示: If a line $l$ connects two points (let's denote them as $\left.A_{1} 、 A_{2}\right)$, by the problem's condition, these two points cannot simultaneously connect to point $A_{1}(i \geqslant 3)$, meaning the number of lines passing through at least one of $A_{1} 、 A_{2}$ is at most $n-1$ (including line $l$). Similarly, for the $n-2$ points $A_{3}, A_{4}, \cdots, A_{n}$, the number of lines passing through at least one of $A_{3} 、 A_{4}$ is at most $n-3$, and so on. Thus,
$$
\begin{array}{l}
k \leqslant(n-1)+(n-3)+(n-5)+\cdots \\
=\left\{\begin{array}{ll}
(n-1)+(n-3)+\cdots+1=\frac{n^{2}}{4}, & \text { if } n \text { is even; } \\
(n-1)+(n-3)+\cdots+2=\frac{n^{2}-1}{4}, & \text { if } n \text { is odd. }
\end{array}\right.
\end{array}
$$

On the other hand, the $n$ points can be divided into two groups:
When $n$ is even, each group has $\frac{n}{2}$ points;
When $n$ is odd, one group has $\frac{n-1}{2}$ points, and the other has $\frac{n+1}{2}$ points.

Connecting each point in the first group to each point in the second group results in $\frac{n^{2}}{4}$ or $\frac{n^{2}-1}{4}$ lines, which satisfy the problem's conditions. If $n$ is even, $k_{\text {min }}$ $=\frac{n^{2}}{4}$; if $n$ is odd, $k_{\min }=\frac{n^{2}-1}{4}$.)
