To find the amount spent on marketing that maximizes the profit \( P \), we start with the profit function given as:
\[ P = -5a^2 + 1000a + 5000 \]
This is a quadratic equation in the form \( P = -5a^2 + 1000a + 5000 \).
To determine the value of \( a \) that maximizes the profit, we use the vertex formula for a parabola, which is given by:
\[ a = -\frac{b}{2a} \]
In our equation, the coefficients are:
- \( A = -5 \) (the coefficient of \( a^2 \))
- \( B = 1000 \) (the coefficient of \( a \))
Plugging in the values into the formula:
\[ a = -\frac{1000}{2(-5)} = -\frac{1000}{-10} = 100 \]
Therefore, the amount spent on marketing that achieves the maximum profit is:
\[ \boxed{100} \quad \text{(in thousands of dollars)} \]