Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, r = map(int, input().split())
- a = list(map(int, input().split()))
- left, right, count = 0, 1, 0
- while right < n and left < n - 1:
- if a[right] - a[left] <= r:
- right += 1
- else:
- count += n - right
- left += 1
- print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement