When the front point of engine crosses the signal post, the speed of trains is u, when the engine has advanced through a distance l, where l is the length of the train, the speed of the last point and hence of the train is v, therefore,
When the engine has advanced through l/2, the middle point of the train must be crossing the signal post.
If at this instant the speed of the middle point (hence of the entire train, including engine) is v, then $ v^2=u^2+2a(l/2)$ -------(ii)
From (i) and (ii) eliminate a to get the answer.
Hence D is the correct answer.