Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #python 3.7.1
- left, right = map(int, input().split())
- nums = [int(i) for i in input().split()]
- partitions = []
- p = []
- for i in nums:
- if i > right:
- partitions.append(p)
- p = []
- else:
- p.append(i)
- partitions.append(p)
- ans = 0
- for p in partitions:
- start = 0
- end = len(p)
- for i, e in enumerate(p):
- if e >= left:
- ans += (i-start+1) * (end-i)
- start = i+1
- print(ans)
Add Comment
Please, Sign In to add comment