[백준] 19941번 : 햄버거 분배 (파이썬)
·
Algorithm/Greedy
그리디 알고리즘 문제 ex) input 12 2 HPHPHPHHPPHP output 6 (1) 처음 내 코드 (실패) a,b=map(int,input().split()) ham = list(input()) # H P cnt=0 for i in range(len(ham)): if ham[i]=="P": change=False for j in range(i-b,i,1): if j=a: continue else: if ham[j]=="H": ham[j]="O" change=True cnt+=1 break if change==False: for j in range(i+b,i,-1): if j=a: continue else: if ham[j]=="H": ham[j]="O" change=True cnt+=1 bre..