Maximize $f:\mathbb R^+ \to \mathbb R$, $x \mapsto \frac{1}{n} \max\{a_1, \ldots, a_n,x\}-cx^2$ 
Given $\{a_1, \ldots, a_n,c\} \subseteq \mathbb R^+$, we define a function $f:\mathbb R^+ \to \mathbb R$ by $$f(x) = \frac{1}{n} \max\{a_1, \ldots, a_n,x\}-cx^2$$ Find the maximizers of $f$.

My attempt:
Let $b := \max_{i} a_i$. Then $$f(x) = \begin{cases} \frac{b}{n} - cx^2 &\text{if} \quad b \ge x \\ \frac{x}{n} -cx^2 &\text{otherwise} \end{cases}$$
To find the maximizers of $f$, we must understand the shapes of $\frac{b}{n} - cx^2$ and $\frac{x}{n} -cx^2$. Their positive roots are $\sqrt{\frac{b}{nc}}$ and $\frac{1}{nc}$ respectively. Moreover, we must know the order of $\sqrt{\frac{b}{nc}}$, $\frac{1}{nc}$, and $b$. In this way, there are so many cases to consider.
Is there a more efficient way to solve this problem? Many thanks!
 A: I'm assuming $\{a_1,\ldots, a_n,c\}\subset{\mathbb R}_{>0}$ and $x\geq0$. Furthermore let $\max\{a_1,\ldots, a_n\}=:b>0$. Then you have correctly
$$f(x)=\left\{\eqalign{{b\over n}-cx^2\qquad&(0\leq x\leq b)\cr{x\over n}-cx^2\qquad&(x\geq b)\ .\cr}\right.$$
This shows that when $x\leq b$ we have
$$\max_{0\leq x\leq b} f(x)={b\over n}\ .$$
For $x\geq b$ we have to look at the expression ${x\over n}-cx^2$. This expression is maximal at $\xi={1\over 2cn}$.
If $\xi<b$, i.e., $2bcn>1$,  then $f(x)$ is decreasing for $x\geq b$. It follows that $$2bcn>1\quad\Rightarrow\quad \max_{x\geq0}f(x)=f(0)={b\over n}\ .\tag{1}$$
If $\xi\geq b$, i.e., $2bcn\leq1$, then
 $$\max_{x\geq b}f(x)=f(\xi)={1\over4cn^2}\ ,$$ 
so that
$$2bcn\leq1\quad\Rightarrow\quad \max_{x\geq0} f(x)=\max\left\{{b\over n},{1\over4cn^2}\right\}={b\over n}\max\left\{1,{1\over4bcn}\right\}\ .\tag{2}$$
Taking $(1)$ and $(2)$ together we see that
$$\max_{x\geq0} f(x)=\left\{\eqalign{{b\over n}\quad\qquad&(4bnc\geq1)\cr{1\over 4cn^2}\qquad&(4bnc\leq1)\cr}\right.$$
