# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
636884 |
2022-08-30T11:15:46 Z |
beaconmc |
JJOOII 2 (JOI20_ho_t2) |
PyPy 3 |
|
32 ms |
18220 KB |
n,k = map(int, input().split())
s = input()
def test1(a):
J=0;O=0;I=0
for p in range(a,n):
i = s[p]
if J==k and O==k and i=="I":
I+=1
elif J==k and i=="O":
O+=1
elif i=="J":
J+=1
return I>=k,I
lo=-1;hi=n
while lo<hi:
mid = (lo+hi+1)//2
if test1(mid)[0]:
lo = mid
else:
hi = mid-1
if lo==-1:
print(-1)
else:
p = "".join(reversed(list(s)))
cnt = 0
ans = 0
for i in p:
if i=="I":
cnt += 1
if cnt > test1(lo)[1]-k:
break
ans += 1
print(n-ans-lo-k*3)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
18220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
18220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
18220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |