### 2011 China National Olympiad #5

Let $a_i,b_i,i=1,\cdots,n$ are nonnegative numbers,and $n\ge 4$,such that $a_1+a_2+\cdots+a_n=b_1+b_2+\cdots+b_n>0$.

Find the maximum of $\frac{\sum_{i=1}^n a_i(a_i+b_i)}{\sum_{i=1}^n b_i(a_i+b_i)}$

We will prove that for $n\ge 4$ we have:

$\frac{\sum_{i=1}^n a_i(a_i+b_i)}{\sum_{i=1}^n b_i(a_i+b_i)} \leq n-1$

WLOG we can suppose $a_1 \ge ... \ge a_n$, and $\sum_{i=1}^{n} a_i=\sum_{i=1}^{n} b_i=1$.
Let's denote $A=\sum_{i=1}^{n} a_i^2$ , $B=\sum_{i=1}^{n} b_i^2$ and $X=\sum_{i=1}^{n} a_ib_i$

We can see that we can always choose numbers such that $A> B$. Now we define: $f(X)=\frac{A+X}{B+X}$, so $f'(X)= \frac{B-A}{(B+X)^2}<0$ what means that we want to minimize $X$ to maximize fraction. From the rearrangement inequality we know that $X$ is minimal when $b_1 \le ... \le b_n$.

Now let's fix $b_1,...,b_n$ and define: $F(a_1,...,a_n)= \frac{A+X}{B+X}$.

We will prove that $F(a_1,a_2,...,a_n)\leq F(a_1+a_2,0,...,a_n)$

But this is obviously true since $a_1^2+a_2^2 \leq (a_1+a_2)^2$ and $a_1b_1+a_2b_2 \ge (a_1+a_2)b_1$.
(Because we increase $A$ and decrease $X$).
We can see that we can repeat this step $n-1$ times, so we conclude: $F(a_1,...,a_n) \leq F(1,0,...,0)$.

It remains to prove: $F(1,0,...,0)=\frac{1+b_1}{\sum_{i=1}^{n} b_i^2 +b_1} \leq n-1$

From Cauchy-Schwarz we have: $\frac{1+b_1}{\sum_{i=1}^{n} b_i^2 +b_1} \leq \frac{1+b_1}{b_1^2 +\frac{(1-b_1)^2}{n-1}+b_1}$

And finally: $\frac{1+b_1}{b_1^2 +\frac{(1-b_1)^2}{n-1}+b_1} \leq n-1 \; \Leftrightarrow b_1(nb_1+n-4) \ge 0$. What clearly holds for $n \ge 4$.

Equality holds when $a_1=1, \; a_2=...=a_n=0$, and $b_1=0, \; b_2=...=b_n= \frac{1}{n-1}$, and we are done. $\square$