I am not sure what I am doing wrong in my solution to this problem:
Find positive numbers $n$ and $a_1, a_2, \dots, a_n$ such that $a_1+a_2+\dots +a_n\le 1000$ and the product $a_1a_2\dots a_n$ is as large as possible.
I have that $AM-GM$ gives us $\dfrac{a_1 + \cdots + a_n}{n} = \dfrac {1000}{n} \ge \sqrt[n]{a_1 \cdots a_n}$. Regardless of $n$, we get equality (and therefore maximum of the product) $\iff$ $a_1 = a_2 = \cdots = a_n$, so the inequality above becomes $\dfrac {1000}{n} = \sqrt[n]{a_1^n}$, or $\dfrac {1000}{n} = a_1$. To maximize $a_1$, we can take $n = 1$. But this is obviously a wrong answer.
EDIT: This is the solution they give:

Note that when $a_1=a_2=\dots=a_n$, then $\frac{1000}n=a_1$. But then you try to find
$$\max[a_n]$$
which is not what we are looking for. What you want is
$$\max[(a_n)^n]=\max\left[\left(\frac{1000}n\right)^n\right]$$
You may however note that since the maximum occurs when $a_1=a_2=\dots=a_n$, then by directly using the original equations:
$$na_1=1000$$
$$a_1=\frac{1000}n$$
$$a_1\times a_2\times\dots\times a_n=(a_1)^n=\left(\frac{1000}n\right)^n$$
Which is much larger than what you initially presumed. By taking the derivative and finding the global maximum for $n\in\mathbb N$, we find the global maximum occurs at $n\approx1000/e=367.8$, and by comparing values around it, $n=368$ is our solution, with
$$a_1=2.718281828\approx e$$
and
$$(a_1)^n=5.8614\times10^{159}$$
for $a_n\in\mathbb N$, this is merely a question of whether $a_1=2$ or some bombination of $2$ and $3$, and this is easy to check that it should be as many $3$'s as possible.