Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. x = int(input())
  2. n = int(input())
  3. a = [int(input()) for i in range(n)]
  4. last = -1
  5. cnt = 0
  6. cnt_rooms = 0
  7. for i in range(n):
  8.     if (a[i] == 1):
  9.         if (last == -1 or cnt_rooms + (i - last) > x):
  10.             cnt += 1
  11.             cnt_rooms = 1
  12.         else:
  13.             cnt_rooms += (i - last)
  14.         last = i
  15. print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement