Let $(X,d)$ be an infinite metric space satisfying H1 or H2 or both.
H1: (All continuous functions on X to $\mathbb{R}$ are bounded.)
If $f: X\to\mathbb{R}$ is continuous on $X$, then $f(x)$ is bounded.
H2: (All continuous functions on $X$ to $\mathbb{R}$ attain a maximum.)
If $f: X\to\mathbb{R}$ is continuous on $X$, then there exists at least one point $p \in X $ such that $f(p) \geq f(x)$ for every $x \in X. $
Question
Does H1 only or does H2 only imply $X$ is compact?
Do H1 and H2 together imply $X$ is compact?
Note:
I know " If $X$ is compact then all continuous functions on $X$ to $\mathbb{R}$ are bounded " and " If $X$ is compact then all continuous functions on $X$ to $\mathbb{R}$ attain a maximum ". I am just curious about whether or not the converse still hold.