第一题 编辑距离
第二题 投病毒
p = input().split(" ")
n = int(p[0])
x = int(p[1])
a = [int(i) for i in input().split(" ")]
intervals = [[i-x, i+x] for i in a]
res = 0
sz = len(intervals)
i = 0
pre = intervals[0]
def merge(a, b):
if a[0]>b[0]:
a, b = b, a
# a[0]<=b[0]
# a[1]>=b[0]
# a包含b
if a[1]>=b[1]:
return b
# a[0]<=b[0] and a[1]<b[1]
# b包含a
# a,b相叠
if a[1]>=b[0]:
return [b[0], a[1]]
return []
while i<sz:
newInterval = merge(pre, intervals[i])
if len(newInterval)==0:
res += 1
pre = intervals[i]
else:
pre = newInterval
i += 1
print(res)
#秋招##笔试##深信服校招##校招#