The reduction in speed is directly proportional to the square root of number of compartment attached.
When there is no compartment attached, then speed would be $42$km/h.
Now suppose $x$ compartment attached and speed reduction will be $24$km/h
Then when speed is $0$, maximum compartment attached
but when speed $0,$ engine cannot move forward.
So, to move forward with minimum speed, we have to attach $49-1=48$ compartments