Advertisement
ilnurav

Untitled

Mar 29th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. x,d = map(float,input().split())
  2. n = int(input())
  3. A = list(map(float,input().split()))
  4. sn1 = x+d
  5. sn2 = x-d
  6. ans = 0;
  7. flag1= 0;
  8. if (A[0] <= x):
  9. flag1 = 0
  10. ans+=1
  11. else:
  12. flag1 = 1
  13. ans+=1
  14. for i in range (1,n):
  15. if (flag1 == 0):
  16. if (A[i] >= sn1):
  17. flag1 = 1
  18. ans+=1
  19. else:
  20. if (A[i] <= x):
  21. ans+=1
  22. else:
  23. if (A[i] <= sn2):
  24. flag1 = 0
  25. ans+=1
  26. else:
  27. if (A[i] > x):
  28. ans+=1
  29. print(n - ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement