Solution (source code)

= Solution

Let $M=\sup_\Omega u$ and suppose $u(y)=M$. The set $\Omega_M=\{x\in\Omega:u(x)=M\}$ is closed in $\Omega$ by <continuity>. If $x\in\Omega_M$, choose a ball $B(x,r)\Subset\Omega$. The <mean value property for harmonic functions> assumed in the question gives
$$
M=u(x)=\frac1{|B(x,r)|}\int_{B(x,r)}u\leq M.
$$
The nonnegative continuous function $M-u$ consequently has integral zero and therefore vanishes throughout the ball. Thus $\Omega_M$ is also open. Since $\Omega$ is <connected> and $\Omega_M$ is nonempty, $\Omega_M=\Omega$, so $u$ is constant. Applying the same argument to $-u$ proves the assertion for an attained infimum.