Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = int(input())
- n = int(input())
- a = [int(input()) for i in range(n)]
- last = -1
- cnt = 0
- cnt_rooms = 0
- for i in range(n):
- if (a[i] == 1):
- if (last == -1 or cnt_rooms + (i - last) > x):
- cnt += 1
- cnt_rooms = 1
- else:
- cnt_rooms += (i - last)
- last = i
- print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement