Submission #4964740


Source Code Expand

Copy
n, k = map(int, input().split())
S = input()
start =[]
end = [0]
if S[0] == "0":
    start.append(0)
for i in range(n):
    if S[i:i+2] == "10":
        start.append(i+1)
    elif S[i:i+2] == "01":
        end.append(i+1)

if len(start) <= k:
    print(len(S))
else:
    start.append(len(S))
    ans = []
    for i in range(len(start) - k):
        ans.append(start[i + k] - end[i])
    print(max(ans))

Submission Info

Submission Time
Task D - Handstand
User sapo
Language Python3 (3.4.3)
Score 400
Code Size 421 Byte
Status
Exec Time 75 ms
Memory 8724 KB

Test Cases

Set Name Score / Max Score Test Cases
All 400 / 400 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 17 ms 3064 KB
sample_02 17 ms 3064 KB
sample_03 17 ms 3064 KB
testcase_01 32 ms 3348 KB
testcase_02 31 ms 3316 KB
testcase_03 65 ms 5468 KB
testcase_04 17 ms 3064 KB
testcase_05 75 ms 7536 KB
testcase_06 74 ms 8724 KB
testcase_07 69 ms 7964 KB
testcase_08 67 ms 8036 KB
testcase_09 67 ms 7968 KB
testcase_10 55 ms 3188 KB
testcase_11 30 ms 3188 KB
testcase_12 31 ms 3188 KB
testcase_13 56 ms 3188 KB
testcase_14 57 ms 3188 KB
testcase_15 17 ms 3064 KB