Determine all pairs $(a, b)$ of real numbers with $a \leq b$ that maximise the integral
$$
\int_{a}^{b} e^{\cos x}\left(380-x-x^{2}\right) \mathrm{d} x .
$$
Write the integrand as
$$
f(x)=e^{\cos x}\left(380-x-x^{2}\right)=-e^{\cos x}(x+20)(x-19),
$$
and observe that it is continuous. Since $e^{\cos x}$ is positive for all real $x$, the integrand $f(x)$ is positive for $-2019$. The essential idea is to interpret the integral as the signed area under the graph of $f(x)$, lying between $x=a$ and $x=b$. Hence, it is maximised when the interval of integration $(a, b)$ includes all positive values of $f(x)$ and does not include any negative values. So the answer is given by $(a, b)=(-20,19)$.

More precisely, let
$$
F(x)=\int_{0}^{x} e^{\cos t}\left(380-t-t^{2}\right) \mathrm{d} t .
$$

We will repeatedly use the fact that if $f(x)>0$ for $x \in(a, b)$ with $a0$. Similarly, if $f(x)-20$ with $a \leq b$. In this case, we have
$$
\begin{aligned}
\int_{-20}^{19} f(x) \mathrm{d} x-\int_{a}^{b} f(x) \mathrm{d} x & =[F(19)-F(-20)]-[F(b)-F(a)] \\
& =[F(19)-F(b)]+[F(a)-F(-20)] \\
& =\int_{b}^{19} f(x) \mathrm{d} x+\int_{-20}^{a} f(x) \mathrm{d} x \\
& \geq 0 .
\end{aligned}
$$

The inequality holds since the first integral in the penultimate line is positive for all $-2019$. Similarly, the second integral in the penultimate line is positive for all $a<-20$, as well as for $-20<a<19$. Therefore,
$$
\int_{-20}^{19} f(x) \mathrm{d} x \geq \int_{a}^{b} f(x) \mathrm{d} x
$$
with equality if and only if $(a, b)=(-20,19)$. This proves our claim.