Solution
Understanding the motion
The elevator descends a distance $S=400\,\mathrm{m}$ in $t=40\,\mathrm{s}$ . During the first half of the descent it accelerates with acceleration $a$ , and during the second half it decelerates with the same magnitude.
The total distance traveled is
$$S=\frac{1}{2}a\left(\frac{t}{2}\right)^2+ \frac{1}{2}a\left(\frac{t}{2}\right)^2 =\frac{at^2}{4}.$$
Therefore,
$$a=\frac{4S}{t^2} =\frac{4\cdot400}{40^2} =1\,\mathrm{m/s^2}.$$
During the first half of the descent, the effective gravitational acceleration for the pendulum is
$$g_{\mathrm{eff},1}=g-a,$$
so its period is
$$T_1=2\pi\sqrt{\frac{l}{g-a}}.$$
During the second half,
$$g_{\mathrm{eff},2}=g+a,$$
and therefore
$$T_2=2\pi\sqrt{\frac{l}{g+a}}.$$
Hence, during the first and second halves of the descent, the numbers of oscillations are
$$n_1=\frac{t/2}{T_1} =\frac{t}{4\pi}\sqrt{\frac{g-a}{l}},$$
and
$$n_2=\frac{t/2}{T_2} =\frac{t}{4\pi}\sqrt{\frac{g+a}{l}}.$$
Thus the total number of oscillations during one descent is
$$n_{\mathrm{d}} =\frac{t}{4\pi\sqrt{l}} \left(\sqrt{g-a}+\sqrt{g+a}\right).$$
If the elevator were not accelerating, the pendulum would make
$$n_0=\frac{t}{2\pi}\sqrt{\frac{g}{l}}$$
oscillations in the same time.
The number of oscillations lost is therefore
$$n_0-n_{\mathrm{d}} =\frac{t\sqrt{g}}{4\pi\sqrt{l}} \left[ 2-\sqrt{1-\frac{a}{g}} -\sqrt{1+\frac{a}{g}} \right].$$
The normal period of the pendulum is
$$T_0=2\pi\sqrt{\frac{l}{g}}.$$
Therefore, the time lost by the clock during one descent is
$$\Delta t=(n_0-n_{\mathrm{d}})T_0.$$
After cancellation,
$$\boxed{ \Delta t= \frac{t}{2} \left[ 2-\sqrt{1-\frac{a}{g}} -\sqrt{1+\frac{a}{g}} \right] }.$$
For $t=40\,\mathrm{s}$ , $a=1\,\mathrm{m/s^2}$ , and$g=9.8\,\mathrm{m/s^2}$ ,
$$\Delta t = 20 \left[ 2-\sqrt{1-\frac{1}{9.8}} -\sqrt{1+\frac{1}{9.8}} \right] \approx 0.054\,\mathrm{s}.$$
The same time loss occurs during an ascent, since the two effective accelerations $g-a$ and $g+a$ simply occur in the opposite order.
In $5$ hours,
$$5\,\mathrm{h}=18000\,\mathrm{s},$$
so the number of ascents or descents is
$$N=\frac{18000}{40}=450.$$
Consequently, the total time lost is
$$\Delta T=N\Delta t =450(0.054) \approx24.3\,\mathrm{s}.$$
Therefore,
$$\boxed{\Delta T\approx24\,\mathrm{s}}.$$