Advertisement
Korotkodul

N1_v1

Apr 27th, 2023 (edited)
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. s=''
  2. with open('f.txt') as f:
  3.     s = f.readline()
  4.  
  5. ans = 0
  6. i = 0
  7.  
  8.  
  9. def f(l):
  10.     global i
  11.     while i + 1 < len(s):
  12.         if s[i] + s[i + 1] == 'QQ':
  13.             return l + 1
  14.         i += 1
  15.         l += 1
  16.         if i + 1 == len(s):
  17.             return l
  18.    
  19.  
  20.  
  21. while i + 1 < len(s):
  22.     if s[i] + s[i + 1] == 'QQ':
  23.         i += 1
  24.         k = f(1)
  25.         ans = max(ans, k)
  26.  
  27.     i += 1
  28.    
  29. print(ans)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement