Advertisement
kerillmp2

Untitled

Dec 22nd, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1.  
  2. l = input().split()
  3.  
  4. cur_len_of_1 = 0
  5. prev_len_of_1 = 0
  6. ans = 0
  7. was_zero = 0
  8.  
  9. for el in l:
  10.     if el == '1':
  11.         cur_len_of_1 += 1
  12.         ans = max(ans, cur_len_of_1 + prev_len_of_1 + was_zero)
  13.     if el == '0':
  14.         prev_len_of_1 = cur_len_of_1
  15.         cur_len_of_1 = 0
  16.         was_zero = 1
  17.  
  18. ans = max(ans, cur_len_of_1 + prev_len_of_1 + was_zero)
  19. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement