Skip to content

Commit d541100

Browse files
committed
[Silver I] Title: IOIOI, Time: 108 ms, Memory: 112428 KB, Score: 100 point -BaekjoonHub
1 parent 4ff138e commit d541100

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
import sys
2+
input = sys.stdin.readline
3+
14
N = int(input())
25
M = int(input())
36
S = input()
47

5-
IOI = 'I' + 'OI' * N
6-
length, cnt = len(IOI), 0
8+
ans, i, cnt = 0, 0, 0
79

8-
for i in range(M - length + 1):
9-
A = S[i:i+length]
10-
if A == IOI: cnt += 1
11-
print(cnt)
10+
while i < (M-1):
11+
if S[i:i+3] == "IOI":
12+
i += 2
13+
cnt += 1
14+
if cnt == N:
15+
ans += 1
16+
cnt -= 1
17+
else:
18+
i += 1
19+
cnt = 0
20+
print(ans)

백준/Silver/5525. IOIOI/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
### 성능 요약
66

7-
메모리: 109544 KB, 시간: 92 ms
7+
메모리: 112428 KB, 시간: 108 ms
88

99
### 분류
1010

1111
문자열
1212

1313
### 제출 일자
1414

15-
2025년 3월 4일 16:09:07
15+
2025년 3월 4일 16:19:07
1616

1717
### 문제 설명
1818

0 commit comments

Comments
 (0)