

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
数直線上に 体のタコ型ロボットと 個の宝があります。
個目の宝はそれぞれ座標 にあります。
タコ型ロボットは つの頭と 本の足を持っており、 本目の足の長さは です。
タコ型ロボットが次のようにして 個の宝すべてを掴む事ができるような整数 の個数を求めてください。
- 頭を座標 におく。
- の順に、「頭から距離 以下の範囲、すなわち をみたす座標 にまだ掴んでいない宝が存在する場合、そのうちの つを選んで掴む」ことを繰り返す。
制約
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
問題文の条件をみたす整数 の個数を出力せよ。
入力例 1Copy
3 -6 0 7 3 5 10
出力例 1Copy
6
が条件をみたします。例えば、 のときは、次のようにして 個の宝をすべて掴む事ができます。
- 本目の足は にある宝を掴む事ができる。このうち座標 にある 個目の宝を掴む。
- 本目の足は にある宝を掴む事ができる。このうち座標 にある 個目の宝を掴む。
- 本目の足は にある宝を掴む事ができる。このうち座標 にある 個目の宝を掴む。
入力例 2Copy
1 0 1000000000000000000
出力例 2Copy
2000000000000000001
以上 以下のすべての整数が として条件をみたします。
入力例 3Copy
2 -100 100 1 1
出力例 3Copy
0
条件をみたす は存在しません。
Score : points
Problem Statement
There is an octopus-shaped robot and treasures on a number line.
The -th treasure is located at coordinate .
The robot has one head and legs, and the -th leg has a length of .
Find the number of integers such that the robot can grab all treasures as follows.
- Place the head at coordinate .
- Repeat the following for in this order: if there is a treasure that has not been grabbed yet within a distance of from the head, that is, at a coordinate satisfying , choose one such treasure and grab it.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number of integers that satisfy the condition in the statement.
Sample Input 1Copy
3 -6 0 7 3 5 10
Sample Output 1Copy
6
satisfy the condition. For example, when , the robot can grab all three treasures as follows.
- The first leg can grab treasures at coordinates satisfying . Among them, grab the first treasure at coordinate .
- The second leg can grab treasures at coordinates satisfying . Among them, grab the second treasure at coordinate .
- The third leg can grab treasures at coordinates satisfying . Among them, grab the third treasure at coordinate .
Sample Input 2Copy
1 0 1000000000000000000
Sample Output 2Copy
2000000000000000001
All integers from to satisfy the condition.
Sample Input 3Copy
2 -100 100 1 1
Sample Output 3Copy
0
No satisfies the conditions.