For the displacement S1 of the body, it can be written that
S1=21a(p−1)2...(1)
And, for the displacement S2 of the body, it follows that
S2=21a(p)2...(2)
If t be the required time, it follows that
S1+S2=21at2...(3)
Equations (1), (2) and (3) imply that
(p−1)2+p2=t2⇒t=2p2−2p+1s