프로그래밍/Python
백준_python 5525번 IOIOI (문자열)
O'bin
2024. 8. 3. 23:05
<문제 링크>
https://www.acmicpc.net/problem/5525
<정답 코드>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import sys
input = sys.stdin.read
N = int(input().strip())
M = int(input().strip())
S = input().strip()
answer, i, count = 0, 0, 0
while i < (M - 2):
if S[i:i+3] == 'IOI':
i += 2
count += 1
if count == N:
answer += 1
count -= 1
else:
i += 1
count = 0
print(answer)
|
cs |