[Day_38] 백준 햄버거 분배 19941_파이썬

LUNA·2023년 5월 3일
0

https://www.acmicpc.net/problem/19941

import sys

n,k=map(int,input().split())
re=list(input())
cnt=0

for i in range(len(re)):
    if re[i]=='P':
        for j in range(i-k,i+k+1):
            if 0<=j<n and re[j]=='H':
                cnt+=1
                re[j]="0"
                break

print(cnt)
profile
Happiness

0개의 댓글