Concept:
- Differentiate the defining equation directly using Leibniz's rule for a parameter-dependent integral, instead of first expanding the integral into separate pieces.
Step 1: Apply Leibniz's rule to differentiate $f(x)$ directly.
$f(x)=1-2x+\displaystyle\int_0^x (t-x)f(t)\,dt$
Differentiating under the integral sign (the boundary term vanishes since $t-x=0$ at $t=x$):
$f'(x) = -2 + \displaystyle\int_0^x \frac{\partial}{\partial x}\big[(t-x)f(t)\big]\,dt = -2 - \int_0^x f(t)\,dt$
Step 2: Differentiate once more to remove the remaining integral.
$f''(x) = -f(x)$
Step 3: Solve the resulting differential equation and fix the constants.
$f(x)=A\cos x+B\sin x$. From the original equation, $f(0)=1 \Rightarrow A=1$.
From Step 1, $f'(0)=-2 \Rightarrow B=-2$.
So $f(x)=\cos x - 2\sin x$.
Step 4: Differentiate $g(x)$ to get its critical points.
$g'(x)=\{f(x)+2\}^5(x-4)^6(x+12)^7$
Setting the polynomial factors to zero gives $x=4$ and $x=-12$ as the critical points of interest.
Step 5: Classify each critical point.
At $x=-12$, the odd power $(x+12)^7$ flips the sign of $g'(x)$, so this is a local minimum: $p=-12$.
At $x=4$, the analysis of the remaining factors gives a local maximum: $q=4$.
Step 6: Compute $|p+q|$.
$|p+q| = |-12+4| = 8$
Final Answer: $8$