Show that function is injective and surjective using given condition on $f$ Consider $f$ a continuous function from $\mathbb{R}$ to $\mathbb{R}$

It is given that $$|f(x)-f(y)|\geq \frac{1}{2}|x-y|\tag{1}$$ for all $x,y$ in $\mathbb{R}$

I want to show that $f$ is one-one and onto

My efforts

Injectivity 

Suppose $a,b\in \mathbb{R}\text{ and } a\neq b$ such that $f(a)=f(b).$

Then consider the following fraction $\frac{f(b)-f(a)}{b-a}$ which is equal to zero as $f(b)=f(a)$ and $b\neq a$

But that is a contradiction as given condition on $f$ says that $|f(b)-f(a)|\geq \frac{1}{2}|b-a|$ and that would actually show that $0\geq \frac{1}{2}|b-a|$ and right hand side is strictly greater than zero.

Therefore function is one one.

Surjectivity 

Let $x_0\in \mathbb{R}$ be any arbitrary point and WLOG assume $x_0\geq 0$. 

If I put $y=0$ condition (1) says $f(x)\geq \frac{1}{2}x+f(0)$ if $x\geq 0$ (also using the fact that WLOG that function is increasing). 

Take $x=2x_0$,

we have $f(2x_0)\geq x_0 +f(0)$ 

Take $x=-2x_0$ and then we have $f(-2x_0)\leq x_0-f(0)$

So we have $f(-2x_0)\leq x_0-f(0)\leq x_0\leq x_0+f(0)\leq f(2x_0)$

Now Intermediate Value theorem works like a magic and we are done!!!!

Am I correct?

Edit: If people are confused, why I can assume that function is increasing in surjectivity part, here is the answer A continuous, injective function $f:\mathbb{R}\rightarrow \mathbb{R}$ is either strictly increasing or strictly decreasing.
The proof doesn't seem to be right, for example, f(x)=-x will make the proof fail.

The conclusion is correct, though: since R is connected, so is the image of f(x). In other words, the image fills a chuck of R. The only thing we need to prove is f(x) is unbounded, which follows immediately from the inequality with y=0.
The proof doesn't seem to be right, for example, f(x)=-x will make the proof fail.

The conclusion is correct, though: since R is connected, so is the image of f(x). In other words, the image fills a chuck of R. The only thing we need to prove is f(x) is unbounded, which follows immediately from the inequality with y=0.