OpenFIPI 2.0
24
6
3380E0
750
s = open('301_24.txt').read().strip()
left = 0
k = 0
right = 0
while k <= 100:
if s[right:right+2] == 'AB':
k += 1
right += 1
mx = right - left - 1
while right < len(s):
# сдвиг левого
while s[left:left+2] != 'AB':
left += 1
left += 1
# сдвиг правого
while right < len(s) and s[right:right+2] != 'AB':
right += 1
right += 1
mx = max(mx, right - left)
print(mx)
## 750
s = s.split('AB')
lens = [len(i) for i in s]
mx = 0
for i in range(len(lens) - 100):
k = sum(lens[i:i + 101]) + 200 + 2
mx = max(mx, k)
print(mx)
Просмотреть отправленные ответы 3380E0