nq1s788

24 отрезок в котором не больше 3х C

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