kimTH65 / Coding

Coding Practice
0 stars 0 forks source link

코딩 문제 풀이 24(AtCoder) - Python #24

Open kimTH65 opened 10 months ago

kimTH65 commented 10 months ago

AtCoder Beginner Contest 332

C - T-shirts image

kimTH65 commented 10 months ago
N,M = map(int,input().split())
S = list(map(str,input().split("0")))

ans = 0
for s in S:
    result = 0
    b = 0
    for i in list(s):
        result+= int(i)

    if result > 0 and result // len(s) > 0 :
        b = result - len(s)

    a = len(s) - b - M

    if a > 0 :
        ans = max(ans,a+b)
    else :
        ans = max(ans,b)