atcoder#ARC060C. [ARC060E] 高橋君とホテル
[ARC060E] 高橋君とホテル
Score : points
Problem Statement
hotels are located on a straight line. The coordinate of the -th hotel is .
Tak the traveler has the following two personal principles:
- He never travels a distance of more than in a single day.
- He never sleeps in the open. That is, he must stay at a hotel at the end of a day.
You are given queries. The -th query is described by two distinct integers and . For each query, find the minimum number of days that Tak needs to travel from the -th hotel to the -th hotel following his principles. It is guaranteed that he can always travel from the -th hotel to the -th hotel, in any given input.
Constraints
- are integers.
Partial Score
- points will be awarded for passing the test set satisfying and .
Input
The input is given from Standard Input in the following format:
:
Output
Print lines. The -th line should contain the minimum number of days that Tak needs to travel from the -th hotel to the -th hotel.
9
1 3 6 13 15 18 19 29 31
10
4
1 8
7 3
6 7
8 5
4
2
1
2
For the -st query, he can travel from the -st hotel to the -th hotel in days, as follows:
- Day : Travel from the -st hotel to the -nd hotel. The distance traveled is .
- Day : Travel from the -nd hotel to the -th hotel. The distance traveled is .
- Day : Travel from the -th hotel to the -th hotel. The distance traveled is .
- Day : Travel from the -th hotel to the -th hotel. The distance traveled is .