Let $f$ be with $\lim_{|x|\to\infty} f(x) = 0$, show that: $\exists x_0\in\mathbb{R}: \, \mid f(x)\mid \, ≤ \, \mid f(x_0)\mid$. 
Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be continuous such that
  $$\lim_{x\to\infty} f(x) = \lim_{x\to -\infty}f(x) = 0$$
  Show that there $\exists x_0\in\mathbb{R}: \, \mid f(x)\mid \, ≤ \, \mid f(x_0)\mid$ for $\forall x \in \mathbb{R}$.

Basically, this means I have to show that $f$ has a maximum on $\mathbb{R}$, right?
There was a theorem in a lecture which said:

Let $f: D \rightarrow \mathbb{R}$ be continuous and $K \subset D$ be compact. Then $f$ has a maximum on $\mathbb{R}$.

However, I cannot use the theorem since $\mathbb{R}$ is not compact. From what I've understood the theorem fails if not compact because there is no maximum if one of the limits is $±\infty$. My approach would've been that:
But since
$$\lim_{x\to\infty} f(x) = \lim_{x\to -\infty}f(x) = 0$$
and obviously
$$ \mid f(x)\mid\, ≥ 0 $$
$f$ must have a maximum on $\mathbb{R} \setminus \{ \infty, -\infty \} $ since f is continuous.
Is the idea acceptable?
 A: The conditions mean that for every $\epsilon > 0,$ there exists an $R>0,$ such that $|f(x)| < \epsilon$ for $|x|>R.$ On the compact set $[-R, R],$ you know that  $|f|$ has a maximum $M.$ If $M > \epsilon,$ that is the global maximum. If not, repeat the argument with $M/2$ in place of $\epsilon.$ This works unless $M = 0,$ in which case, double $R.$ If the maximum is always $0$ then the function is the constant $0,$ and you are done. 
A: Let's look at a sub problem, 

Let $\, f : \mathbb{R} \to \mathbb{R}$ be continuous s.t.
  $$
f(x) > 0 \; \forall x \in \mathbb{R}, \lim_{x \to \infty} f(x) = \lim_{x \to -\infty} f(x) = 0
$$
  then $\exists \, x_0 \in \mathbb{R}$ s.t. $f(x) \le f(x_0) \; \forall x \in \mathbb{R}$

Let $a_n$ be a sequence in $\mathbb{R}$ s.t.
$$
a_n > 0 \; \forall \; n \in \mathbb{N}, \lim_{n \to \infty} a_n = \infty
$$
(note this is notation that says $a_n$ is unbounded).
Now create the set $A = \left\{ m_k \mid k \in \mathbb{N} \right\}$ where $m_k$ is the maximum specified by the theorem you referred to on the compact set $[-a_k, a_k]$ (bounded closed sets in $\mathbb{R}^n$ are compact). Now all that's left to prove is that $\sup A = \max A$ or that the maximum is actually achieved (which you can prove using the continuity of $f$ and strict positiveness of $f$).
Once you've proved this you should be able to extend this to what you want.
