The worm climbs 2 cm and falls 1 cm in 5 minutes.
So it effectively climbs (2-1)=1cm in 5 minutes.
For the first 8cm, it will take (8×5) = 40 minutes
At the end of 40 minutes, it will be at 8 cm.
Then in another 5 minutes it will reach the top. Once it reaches the top, it won't fall again.
So the total time is 40+5=45 minutes