## A. Mean Inequality

### Solution:

Sort the array. And split the array to two parts. Each time, we take one number from each of the two parts at a time.

### Code:

Java

C++

## B. I Hate 1111

### Solution:

Consider 1111, we found that $1111=11\times 101$. In same way, we only need consider if the number can be built by 11 and 111.

Let $x=a\cdot 11 + b\cdot 111$. when $b>11$, $x=a\cdot 11 + 11 \cdot 111 + (b-11)\cdot 111=(a+111)\cdot 11 + (b-11) \cdot 111$. So, if there is a solution, then we must can find the solution which $b<11$. So, just enumerate the b.

### Code:

Java

C++

## C. Potions

Tried to find some $n^2$ solution, so that can pass easy version only. But I cannot find that.

And for this problem, it is obviously, just calculating the prefix sum. When the sum is less than 0, we spit the worst potion.

## D. Kill Anton

The conclusion is: in the answer, the four letters must be consecutive. So just enumerate the permutation of four letters and see which one can make largest cost.

## E. Oolimry and Suffix Array

After I build the 4th sample data, then this problem is solved. The point is: find out the way to handle the case which string have duplicate character.