Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def main():
  2.     n = int(input())
  3.     photo = [int(x) for x in (input().split())]
  4.     color = dict()
  5.     cnt = 0
  6.     for i in range(n):
  7.         if i == 0:
  8.             cnt += 1
  9.             continue
  10.         if photo[i] == photo[i - 1]:
  11.             cnt += 1
  12.         if photo[i] != photo[i - 1]:
  13.             color[cnt] = 1
  14.             cnt = 1
  15.         if i == n - 1:
  16.             color[cnt] = 1
  17.     if len(color) <= 1:
  18.          print('YES')
  19.     else:
  20.         print('NO')
  21.  
  22. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement