$u$ upper semicontinuous iff for all $K \subseteq U$ compact and $g \in C(K)$, $u - g$ attains its maximum on $K$? As the question title suggests, how do I see that $u$ is upper semicontinuous if and only if, for all $K \subseteq U$ compact and $g \in C(K)$, the difference $u - g$ attains its maximum on $K$?

Here's the first half to get you started...
A function $u\in C(U)$ is upper semicontinuous provided that for all $x \in U$, and for all sequences $(x_n)_{n=1}^{\infty}\subset U$ such that $x_n \rightarrow x$, $$\limsup u(x_n) \leq u(x)$$
I make the assumption that you're considering real-valued functions on a metric space.
($\implies$)
First we show that $u$ is bounded above on $K$. Assume $u$ is not bounded above. Then there exists a sequence $(x_n) \subset K$ such that $u(x_{n+1})>u(x_n)+1$ for each $n$. As $K$ is compact, there exists a convergent subsequence $(x_{n_{k}}) \rightarrow x \in K$, and as $u$ is upper semicontinuous, $\limsup u(x_{n_k}) \leq u(x)$. But this would imply $u(x)=\infty$, so $u$ is bounded above.
As $u(K)$ is bounded, it has a least upper bound $M$ meaning we can construct a sequence $(x_n)$ such that $f(x_n) > M - 1/n$. Again, as $K$ is compact we take a convergent subsequence $x_{n_k}\rightarrow x\in K$ and note that for each $n$ we have $$M-1/n<u(x_{n_k})\leq u(x) \leq M$$ so $u(x)=M$. 
As $g$ is a continuous function we have $\lim g(x_n) \leq g(x)$, so $\limsup (u-g)(x_n) \leq (u-g)(x)$ and $u-g$ is upper semicontinuous. We can then apply the above argument.
