From definition of speed,
Distance = Speed × Time
The total distance will be the sum of the distances travelled in both the time intervals.
In the first part of motion,
Speed=20 km h−1, Time=2 h
Distance travelled:
D1=20×2=40km
In the second part of motion,
Speed=30 km h−1, Time=1 h
Distance travelled:
D2=30×1=30km
Hence, total distance: D=D1+D2=70km