Do you know Popeye? He likes spinach(菠菜) very much. Maybe you have played some games about him. Now here comes one game.
There are many boards, on one board there is a heart, Popeye wants to catch the heart and send it to his GF, Oliver, so that, she will be happy.
At the beginning, Popeye is on one board, and the heart is on another board. Every board is described as h, l, and r, the height, the left end and the right end. You can look it as a line (l, h) (r, h) in XY coordinate system. Popeye can walk on the board, jump from one board to another.
Notes:
1.He can walk on a board 1 unit per second.
2.He can only jump vertically(垂直地), and it takes 1s for each jumping.
3.He can jump only 1 unit high, so that he can jump only if the difference of the boards’ height is 1.
4.He can only jump up to the left or right point of the board.
5.He can only jump down from the left or right point of the board.
You can look the picture:
The problem is, find the shortest time to catch the heart.