compact can be translated as closed and bounded, which means that f has to be a bounded function (you can prove this by contradiction, here is where you use the fact f is continuous). Since f is bounded, the set has a supremum and infimum. Which are the maximum and minimum values of f respectively.