5. A moving point $P$ starts from the origin on the number line and moves in the positive direction of the number line according to the procedure of advancing 5 units and then retreating 3 units. It is known that $P$ advances or retreats 1 unit per second, and let $x_{n}$ represent the number corresponding to the position of point $P$ on the number line at the $n$-th second (for example, $x_{4}=4, x_{5}=5, x_{6}=4$). Then $x_{2011}$ is ( ).
(A) 504
(B) 505
(C) 506
(D) 507
5. B.

Notice that,
$$
2011=8 \times 251+3,2 \times 251+3=505 \text {. }
$$

Therefore, the answer is B.