As $\displaystyle f$ is surjective, $\displaystyle \forall y \in \mathbb{B}$, $\displaystyle \exists$ $\displaystyle a \in \mathbb{A}$ such that $\displaystyle f(a)=y$. Each element of $\displaystyle \mathbb{B}$ has an antecedent in $\displaystyle \mathbb{A}$.

Hence there exists a function $\displaystyle g$ such that $\displaystyle g(y)=a$ and $\displaystyle g(z) \neq a \forall z \in \mathbb{B}$ and $\displaystyle z \neq y$.

If $\displaystyle f(a)=y \Rightarrow$ $\displaystyle g(y)=a$, which means $\displaystyle f$ is invertible. (Proof completed.)

I hope I didn't make any error.