Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, m = map(int, input().split())
- positions = list(map(int, input().split()))
- current_sum = 0
- modulo = 1000000007
- for index in range(1, m + 1):
- current_sum += positions[index - 1]
- current_sum %= modulo
- if positions[index]:
- positions[index] = current_sum
- for index in range(m + 1, n):
- current_sum -= positions[index - m - 1]
- current_sum += positions[index - 1]
- current_sum %= modulo
- if positions[index]:
- positions[index] = current_sum
- print(positions[-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement