CF1004A.Sonya and Hotels
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.
The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has n hotels, where the i -th hotel is located in the city with coordinate xi . Sonya is a smart girl, so she does not open two or more hotels in the same city.
Sonya understands that her business needs to be expanded by opening new hotels, so she decides to build one more. She wants to make the minimum distance from this hotel to all others to be equal to d . The girl understands that there are many possible locations to construct such a hotel. Thus she wants to know the number of possible coordinates of the cities where she can build a new hotel.
Because Sonya is lounging in a jacuzzi in one of her hotels, she is asking you to find the number of cities where she can build a new hotel so that the minimum distance from the original n hotels to the new one is equal to d .
输入格式
The first line contains two integers n and d ( 1≤n≤100 , 1≤d≤109 ) — the number of Sonya's hotels and the needed minimum distance from a new hotel to all others.
The second line contains n different integers in strictly increasing order x1,x2,…,xn ( −109≤xi≤109 ) — coordinates of Sonya's hotels.
输出格式
Print the number of cities where Sonya can build a new hotel so that the minimum distance from this hotel to all others is equal to d .
输入输出样例
输入#1
4 3 -3 2 9 16
输出#1
6
输入#2
5 2 4 8 11 18 19
输出#2
5
说明/提示
In the first example, there are 6 possible cities where Sonya can build a hotel. These cities have coordinates −6 , 5 , 6 , 12 , 13 , and 19 .
In the second example, there are 5 possible cities where Sonya can build a hotel. These cities have coordinates 2 , 6 , 13 , 16 , and 21 .