Suppose that a function $f : D \to \mathbb R$ is non-decreasing (i.e., for any two values $x$ and $y$ in its domain such that $x \ge y$, we have $f (x) \ge f(y)$) but not necessarily continuous. Let $D$ be compact. Show that if $n = 1$, $f$ always has a maximum on $D$. Show that if $n > 1$, this need not be true.
For this, I am trying to prove with Extreme Value Theorem, but I can't use this theorem because the function is not continuous. Can I use Heine-Borel Theorem here? Can I prove as follows?
Since $f$ is non-decreasing function, we have $f(x)\ge f(y)$ whenever $x\ge y$. Since the domain is compact, it is closed and bounded so by Heine-Borel theorem, we can find the max and min on the domain. But, this is not true when $n>1$ because $D= \{-x,x\}$ and $f(x)=\frac 1 n$. Then, $D$ is closed and bounded but we can't really find a max and min when $x$ goes to infinity.
This is my thought so far. Any hints would be greatly appreciated. Thanks so much.