#abc318f. F - Octopus
F - Octopus
Score : points
问题描述
在数轴上有一个章鱼形状的机器人和个宝藏。第个宝藏()位于坐标处。
该机器人有一个头部和条腿,其中第条腿()的长度为。
找出满足以下条件的整数 的数量,使得机器人可以按照如下方式抓取所有个宝藏。
- 将头部放置在坐标处。
- 按照顺序依次对执行以下操作:若存在一个尚未被抓住的宝藏,且其距离头部的距离在以内,即存在一个坐标满足,则选择其中一个这样的宝藏并抓取它。
以上为通义千问 qwen-max 翻译,仅供参考。
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 1
3
-6 0 7
3 5 10
Sample Output 1
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 2
1
0
1000000000000000000
Sample Output 2
2000000000000000001
All integers from to satisfy the condition.
Sample Input 3
2
-100 100
1 1
Sample Output 3
0
No satisfies the conditions.
update @ 2024/3/10 09:05:06