var1 = input()
n, k = int(var1.split(" ")[0]), int(var1.split(" ")[1])
s = input()
def check(n, k, s):
ind = 0
j_count, o_count, i_count = 0, 0, 0
while (j_count < k) and (ind < len(s)):
if s[ind] == "J":
j_count += 1
ind += 1
while (o_count < k) and (ind < len(s)):
if s[ind] == "O":
o_count += 1
ind += 1
while (i_count < k) and (ind < len(s)):
if s[ind] == "I":
i_count += 1
ind += 1
if (j_count != k) or (o_count != k) or (i_count != k):
return -1
else:
return 1
if check(n, k, s[1:-1]) == 1:
print(len(s)-2-k*3)
elif check(n, k, s[1:]) == 1:
print(0)
elif check(n, k, s) == 1:
print(0)
else:
print(-1)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
2900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
2900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
2900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |