Submission #636935

# Submission time Handle Problem Language Result Execution time Memory
636935 2022-08-30T14:59:38 Z beaconmc JJOOII 2 (JOI20_ho_t2) PyPy 3
0 / 100
34 ms 18156 KB
from bisect import *
from math import *
n,k = map(int, input().split())
s = input()

pref1 = [int(s[0]=="J")]
pref2 = [int(s[0]=="O")]
pref3 = [int(s[0]=="I")]

for i in range(1,n):
    pref1.append(pref1[-1]+(s[i]=="J"))
    pref2.append(pref2[-1]+(s[i]=="O"))
    pref3.append(pref3[-1]+(s[i]=="I"))

ans = n+1
for i in range(n):
    a = bisect_left(pref1,k+i)
    if a>=n:continue
    b = bisect_left(pref2, pref2[a]+k)
    if b>=n:continue
    c = bisect_left(pref3, pref3[b]+k)
    if c>=n:continue
    
    ans = min(ans, c-a-2*k)
    print(a,b,c)
print(ans)
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 18156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 18156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 18156 KB Output isn't correct
2 Halted 0 ms 0 KB -