nq1s788

24 максимальная <= 3 X

Mar 21st, 2026
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. s = open('').readline()
  2. l = 0
  3. r = 0
  4. if s[0] == 'X':
  5.     cnt_x = 1
  6. else:
  7.     cnt_x = 0
  8. answ = 1
  9. while r < len(s):
  10.     if r + 1 < len(s) and (cnt_x < 3 or (cnt_x == 3 and s[r + 1] != 'X')):
  11.         r += 1
  12.         if s[r + 1] == 'X':
  13.             cnt_x += 1
  14.         answ = max(answ, r - l + 1)
  15.     else:
  16.         while s[l] != 'X':
  17.             l += 1
  18.         l += 1
  19.         cnt_x -= 1
  20. print(answ)
Advertisement
Add Comment
Please, Sign In to add comment