First, we'll check whether $f$ a valid function from $\mathbb{Z}$ to $\mathbb{Z}$ or not.
For any integer $n$, the value $3n+1$ is an integer. Therefore, $\frac{3n+1}{2}$ is a real number. The floor function $\lfloor x \rfloor$ maps any real number $x$ to the greatest integer less than or equal to $x$. This means the output will always be an integer. Thus, $f$ is a well-defined function from $\mathbb{Z}$ to $\mathbb{Z}$. This eliminates Option A.
Now, we'll check if $f$ one-to-one (injective) or not.
Let's see how the function grows by calculating $f(n+1) - f(n)$:
$$f(n+1) = \left\lfloor \frac{3(n+1)+1}{2} \right\rfloor = \left\lfloor \frac{3n+4}{2} \right\rfloor = \left\lfloor \frac{3n+1}{2} + 1.5 \right\rfloor$$
Depending on whether $n$ is even or odd, $\frac{3n+1}{2}$ will either be an integer or end in $.5$.
If $\frac{3n+1}{2}$ ends in $.5$, adding $1.5$ increases the floor value by exactly $2$.
If $\frac{3n+1}{2}$ is an integer, adding $1.5$ increases the floor value by exactly $1$.
In all cases, $f(n+1) > f(n)$. Because the function is strictly increasing, it is impossible for two different inputs to produce the same output. Therefore, $f$ is one-to-one.
Now, we'll check if $f$ onto (surjective) or not.
Let's test a few consecutive integer inputs to see the sequence of outputs:
$f(0) = \lfloor 1/2 \rfloor = 0$
$f(1) = \lfloor 4/2 \rfloor = 2$
$f(2) = \lfloor 7/2 \rfloor = 3$
$f(3) = \lfloor 10/2 \rfloor = 5$
Notice that the output skips the integer $1$. Since we already established that the function is strictly increasing, it will never "go back" to hit $1$. Because there is an integer in the codomain ($y=1$) that is not mapped to by any integer $n$ in the domain, the function is not onto.
Conclusion : The function $f$ is one-to-one but not onto. The correct option is B.