快速IO,然后用if-else分别模拟求出最大最小值即可
from sys import stdin, stdout
def main():
input = stdin.readline
n,x = map(int,input().split())
if n == 1:
print("0 0")
return
l = [int(i) for i in input().split()]
cntmax = 0
cntmin = 0
# cntmax
if l[0] != -999999999:
start = l[0]
else:
start = 500000000
for i in range(1,n):
if l[i] != -999999999:
if start-l[i] >= x:
cntmax += 1
start = l[i]
else:
if start-x>= -500000000:
start -= x
cntmax += 1
else:
start = 500000000
# cntmin
if l[0] != -999999999:
start = l[0]
else:
start = -500000000
for i in range(1,n):
if l[i] != -999999999:
if start-l[i] >= x:
cntmin += 1
start = l[i]
else:
start = max(-500000000,start - x + 1)
print(cntmax,cntmin)
if __name__ == "__main__":
main()