# Find the maximum and minimum of $\sum \limits_{i=1}^n x_i ^3$ given three constraints

Let $$x_1,x_2, \dots ,x_n$$ be a sequence of integers such that

$$i)\quad\ \ -1\le x_i\le 2$$ for $$i=1,2,\dots,n$$

$$ii)\quad \ \,x_1+x_2+\dots+x_n=19$$

$$iii)\quad{x_1}^2+{x_2}^2+\dots +{x_n}^2=99$$

Determine the minimum and maximum values of $$\sum \limits_{i=1}^n x_i^3$$

I tried using the Cauchy-Schwarz inequality, and some others, but it appears something difficult. I think I am missing something.

A simple approach would be to simply count the numbers of $x_i$ taking the values $-1$, $1$ and $2$. Denote these numbers by $a$, $b$ and $c$, respectively. Then we have \begin{eqnarray*} \sum_{i=1}^nx_i &=&-1\times a+1\times b+2\times c &=& 19,\\ \sum_{i=1}^nx_i^2 &=&\ \quad1\times a+1\times b+4\times c &=& 99. \end{eqnarray*} This shows that $a+c=40$, so $c=40-a$ and $b=3a-61$. Then \begin{eqnarray*} \sum_{i=1}^nx_i^3&=&-1\times a+1\times b+8\times c=-a+(3a-61)+8(40-a)=259-6a,\\ \end{eqnarray*} where of course $21\leq a\leq40$ because $b,c\geq0$, which shows that we have sharp bounds $$19\leq\sum_{i=1}^nx_i^3\leq133.$$