You can view the solution by clicking on the solution tab.
Editorial
Need a hint? Checkout the editorial.
View Editorial
Editorial
Let $a$ be the number of $2$'s. Find the hocus-pocus sum in terms of $a$.
Whenever Avik gets a sequence, he multiplies every two distinct terms of that sequence, and then sums up these products to get the 'Hocus-pocus' sum of the sequence. For example, the 'Hocus-pocus' sum for the sequence $a, b, c, d$ is $ab + ac + ad + bc + bd + cd$. If Avik gets a sequence of $100$ terms, where each term is either $2$ or $-1$, what is the minimum 'Hocus-pocus' sum of that sequence?
Source: BdMO 2017 National Junior P10
Let $a$ be the number of 2's in the sequences. So, the number of -1's in the sequence is $100-a$.
Now, let $H_A$ be the $hocus-pocus$ sum of the sequence $A$. So,
\[H_A=4\binom{a}{2}+\binom{100-a}{2}-2a(100-a)\]
\[=2a^2-2a+\frac{(100-a)(100-a-1)}{2}-200a+2a^2\]
\[=4.5a^2-301.5a+4950\]
The value of a quadratic equation $ax^2+bx+c$ is the lowest (or highest if $a$ is negative) when the variable is at the vertex, i.e. $a=\frac{-b}{2a}$
The vertex of this equation is $\frac{-(-301.5)}{2\cdot 4.5}=33.5$
But, $a$ must be an integer. So, taking the integers closest to the vertex, taking $a=33$, we see $H_A=-99$
Taking $a=34$, again, $H_A=-99$
So, the least value of $H_A$ is $-99$.
Let $a$ be the number of $2$'s. Find the hocus-pocus sum in terms of $a$.