Let the times taken for the stretches be x,2x,3x hrs.
The respective speeds are 20,30,40 kmph.
Distance covered in every stretch stretch = Time taken in that stretch * Speed in that stretch
Thus respective distances are x*20 , 2x*30 , 3x*40 kms respectively.

Total distance being 100km,
x*20 + 2x*30 + 3x*40 =100
=>200x =100
=>x= 1/2

Thus total time= x+2x+3x=6x
= 6*(1/2) =3hrs (OPTION D)