If it's solvable, then $k\le \lfloor{\frac{n}{2}}\rfloor$ ($\lfloor x\rfloor$ is the floor function in case you didn't know). We get that because each student has to have space around them if you start from the very front and go student space student space ... and continue like this it's like choosing a container of two to put each student in. There are at most $\frac{n}{2}$ of these containers of two. Therefore, via the pigeonhole principle, there can't be more than $\frac{n}{2}$ students. There are two cases that can eventually be combined either the first student is at the very front or one seat back. Now, the representation of multiplying all the positive numbers together up to a number n! . You can also define multifactorials as: $n\underbrace{!...!}_m=\prod_{d=0}^{\lfloor {\frac{n}{m}}\rfloor} n-dm$
This comes in use, because, with m=2 we have n$\cdot(n-2)...$ which means, the first student has n seats to choose from, the second has n-2 ... (not the seat the first student had or the one behind it if they are in the very front). The teacher could also have started the spacing starting with the first student at the second desk in the row leading to $(n-1)\cdot (n-3)...$ . To spread out the students like this, has taken up $2\cdot k-1$ seats from either representation so in the first case we have $\frac{n!!}{(n-2\cdot k)!!}$ , and the second case $\frac{(n-1)!!}{(n-2\cdot k-1)!!}$ and depending on ordering of things mattering you can divide by $k!\cdot (n-k)!$ for the arrangements of the students and the empty chairs ( as if ordering doesn't matter all the students are the same and all the empty chairs are the same when put in the same places).
at least that's the best explanation I can give.