$$
f(n)=\left\{\begin{array}{ll}
1, & n=1 \text { when; } \\
2, & 1<n \leqslant 3 \text { when; } \\
3, & 3<n \leqslant 6 \text { when; } \\
\cdots \cdots . & \\
m, & \frac{m(m-1)}{2}<n \leqslant \frac{m(m+1)}{2} \text { when; } \\
\cdots \cdots . &
\end{array}\right.
$$

If $S_{n}=\sum_{k=1}^{n} f(k)=2001$, find the value of $n$.
By $1^{2}+2^{2}+\cdots+17^{2}=1785$,
$$
1^{2}+2^{2}+\cdots+18^{2}=2109,
$$

and $1785<2001<2109$,
we know that the last term of the sum $S_{n}=f(1)+f(2)+\cdots+f(n)$ appears in the 18th row, thus, $f(n)=18$.

Also, $1+2+\cdots+17=153$, so $S_{n}$ can be divided into two parts: the first part is the sum of the numbers in the first 17 rows $1^{2}+2^{2}+\cdots+17^{2}$, and the second part is the sum of $n-153$ numbers of 18 in the 18th row. Therefore,
$$
\begin{array}{l}
S_{n}=S_{1+2+\cdots+17}+[n-(1+2+\cdots+17)] f(n) \\
=\left(1^{2}+2^{2}+\cdots+17^{2}\right)+(n-153) \times 18 \\
=1785+18 n-2754=18 n-969 .
\end{array}
$$

Hence, $18 n-969=2001$.
Therefore, $n=165$.