Label the positions, left-to-right, as $1,2,3,...,10$.
Suppose there is some arrangement which satisfies the specified conditions.
Let $x_k,y_k$ with $x_k < y_k$ be the positions of the two people from department $k$.
\begin{align*} \text{By hypothesis,}\;\,&y_k - x_k = k+1,\;\text{for all k}\\\\[4pt] \text{hence}\;&\sum_{k=1}^5(y_k-x_k)=\sum_{k=1}^5(k+1)=20\\\\[4pt] \implies\;&\sum_{k=1}^5y_k-\sum_{k=1}^5 x_k=20\\\\[8pt] \text{But also}\;&\sum_{k=1}^5y_k+\sum_{k=1}^5 x_k=1 + 2 + 3 + \cdots + 10 = 55\\\\[8pt] \text{hence}\;& \left(\sum_{k=1}^5y_k+\sum_{k=1}^5 x_k\right)+ \left(\sum_{k=1}^5y_k-\sum_{k=1}^5 x_k\right) =55 + 20\\\\[4pt] \implies\;&2\sum_{k=1}^5y_k = 75\\\\[4pt] &\text{contradiction, since}\\\\[4pt] &2\sum_{k=1}^5 y_k\;\text{must be even.}\\\\[4pt] \end{align*}