Show $g(a)= \operatorname*{arg}_{b \in B} \, f(a,b)=0$ is continuous when $g(a)$ is single-valued and $f$ continuous Let $A$ and $B$ be two compact subsets of $\mathbb{R}$. Let $f:A \times B \to \mathbb{R}$ be a continuous function on $A \times B$.
For each $a\in A$, define $B_a=\{b\in B:f(a,b)=0\}$, and suppose each $B_a$ is a singleton, so we may define a $g:A\to\Bbb R$ such that $g(a)$ is the unique element of $B_a$ for each $a\in A$. Is $g$ a continuous function of $a$?  
I tried the following. But I have the feeling it's not correct.  
Assume $g$ is not continuous at $a \in A$, then there exists a sequence $\{a_n\} \subset A$ converging to $a$ in $A$,
for which the sequence $\{b_n\}=\{g(a_n)\} \subset B$ does not converges to $b=g(a)$.
Since $B$ is compact, by the Bolzano-Weierstrass theorem, $\{b_n\}$ has a subsequence $\{b'_n\}$ 
converging to some $b'\ne b$ as $\{b_n\}$ does not converges to $b$. 
Let $\{a'_n\} \subset A$ be the subsequence of $\{a_n\}$ induces by $\{b'_n\}$.
Since $\{a_n\}$ converges to $a$ then every subsequence of $\{a_n\}$ converges to $a$ and $\{a'_n\}$ converges to $a$.
Since $g(a)$ contains a unique element $b$, then  $b'=b$ which is a contraction since $\{b'_n\}$ is a subsequence of $\{b_n\}$. (The previous sentence seems suspicious).
The claim follows.
 A: I found the following proof by borrowing from Berge Maximum theorem proof strategy.
Do you think it's ok?
(The beginning is similar then my previous proof, I have indicated the new content)
I improved this paragraph per Cameron help
Assume $g$ is not continuous at $a \in A$, then there exists a sequence $\{a_n\} \subset A$ converging to $a$ and an $\epsilon>0$ such that for each $n$,  $b_n=g(a_n)$ and $|b_n-b|>\epsilon$ where $b=g(a)$.
Since $B$ is compact, by the Bolzano-Weierstrass theorem, $\{b_n\}$ has a subsequence $\{b'_n\}$ 
converging to some $b'\ne b$ as $\{b_n\}$ is never in the neighborhood $(b-\epsilon,b+\epsilon)$ of $b$.  
Let $\{a_n'\} \subset A$ be the subsequence of $\{a_n\}$ induced by $\{b'_n\}$.
Since $\{a_n\}$ converges to $a$ then every subsequence of $\{a_n\}$ converges to $a$ and $\{a'_n\}$ converges to $a$.
new content
Since $f$ is continuous then $f(a'_n,b'_n)$ converges to $f(a,b')$.
Since $g(a)$ is the singleton $b$ then $b'$ is not a root of $f(a,\cdot)$.
Whence, either $f(a,b')>f(a,b)$ or $f(a,b')<f(a,b)$.
Since $B$ is compact there is sequence $\{\bar b_n\} \subset B$ converging to $b$.
By continuity of $f$, $f(a'_n,\bar b_n)$ converges to $f(a,b)$.
If $f(a,b')>f(a,b)$, then there is an $n_0$ for which $f(a'_n,b'_n)>f(a'_n,\bar b_n)$ when $n \ge n_0$.
Since $b'_n=g(a'_n)$, then $0>f(a'_n,\bar b_n)$ for $n \ge n_0$ and $0>f(a,b)$, which is a contradiction 
since $b$ is a root of $f(a,\cdot)$.
Similarly, we cannot have $f(a,b')<f(a,b)$ and hence $f(a,b')=f(a,b)$.
Since, $g(a)$ is the singleton $b$, $b=b'$, which is a contradiction.
Thus, $g$ is continuous at $a$.
A: Let's assume that $g$ is not continuous at $a$. Thus, there is a sequence $\{a_n\}$ such that $a_n$ converges to $a$, but such that $b_n:=g(a_n)$ fails to converge to $b:=g(a)$.
By definition, this means that there exists some $\epsilon$ such that for all $N$, there is some $n\geq N$ with $|b_n-b|>\epsilon$--that is, there are infinitely many $n$ such that $|b_n-b|>\epsilon$. Let $\{b_n'\}$ be a subsequence of $\{b_n\}$ with $|b_n'-b|>\varepsilon$ for all $n$ (possible by "infinitely many"), and observe that neither $\{b_n'\}$ nor any of its subsequences can converge to $b$ (I leave it to you to justify this).
Since $\{b_n'\}$ is a sequence of points of the compact set $B$, then by B-W, there is a convergent subsequence $\{b_n''\}$ of $\{b_n'\}$. As noted above, $\{b_n''\}$ must converge to something other than $b$. Observing that $\{b_n''\}$ is a subsequence of $\{b_n\}$, too, then we may assume without loss of generality that $b_n'=b_n''$ for all $n$, meaning that in fact $b_n'$ converges, say to $b'\neq b$. (The only thing you hadn't done is justified why we could assume that your chosen subsequence $\{b_n'\}$ converges. So close!)
Then we induce $\{a_n'\}$ from $\{b_n'\}$ and continue as you described.
