extended real valued function bounded below and attains its minimal value

Let f(x) be a real-valued function (an extended real valued function) on a metric space (M; d). Then

$\displaystyle \lim\sup_{x\rightarrow y}f(x)=\lim_{\epsilon\rightarrow0}\sup_{0<d(x,y)<\ epsilon}f(x)$

and

$\displaystyle \lim\inf_{x\rightarrow y}f(x)=\lim_{\epsilon\rightarrow0}\inf_{0<d(x,y)<\ epsilon}f(x)$

A function is called lower (upper) semicontinuous at a point y if $\displaystyle f(y)\neq\pm\infty$

and

$\displaystyle f(y)=\leq\liminf_{x\rightarrow y}f(x)$ and

$\displaystyle f(y)=\geq\limsup_{x\rightarrow y}f(x)$

Let a metric space M be complete, and let K be a compact subset in M. Prove that a lower semicontinuous function on K is bounded from below and attains its minimal value and an upper semicontinuous function on K is bounded from above and attains its maximal value.

Any idea of how to approach this??