5. Let $[x]$ denote the greatest integer not exceeding the real number $x$. Given $0<a<1$, and
$$
\begin{array}{l}
{\left[a+\frac{1}{2020}\right]+\left[a+\frac{2}{2020}\right]+\cdots+\left[a+\frac{2019}{2020}\right]} \\
=2018 .
\end{array}
$$

Then the value of $[1010 a]$ is ( ).
(A) 1000
(B) 1005
(C) 1008
(D) 1009
5. D.

Notice,
$$
\begin{array}{l}
0<a+\frac{1}{2020}<a+\frac{2}{2020}<\cdots<a+\frac{2019}{2020}<2 . \\
\text { Then }\left[a+\frac{1}{2020}\right],\left[a+\frac{2}{2020}\right], \cdots,\left[a+\frac{2019}{2020}\right]
\end{array}
$$

equals 0 or 1.
By the problem, we know that 2018 of them equal 1.
$$
\begin{array}{l}
\text { Therefore, }\left[a+\frac{1}{2020}\right]=0, \\
{\left[a+\frac{2}{2020}\right]=\left[a+\frac{3}{2020}\right]=\cdots=\left[a+\frac{2019}{2020}\right]=1. } \\
\text { Hence } 0 \leqslant a+\frac{1}{2020}<1,1 \leqslant a+\frac{2}{2020}<2 \\
\Rightarrow \frac{1009}{1010} \leqslant a<\frac{2019}{2020} \\
\Rightarrow 1009 \leqslant 1010 a<1009.5 \text {. } \\
\end{array}
$$

Therefore, $[1010 a]=1009$.