

나의 코드
import copy
def solution(want, number, discount):
answer = 0
#일단 딕셔너리를 만들어주자
dict = {}
for i in range(len(want)):
dict[want[i]] = number[i]
index = 0
#10일치 만큼만 반복문
while index <= len(discount)-10:
#deepcopy를 안쓰게되면 참조하게 되서 dict도 같이 수정됨
new_dict = copy.deepcopy(dict)
#10일치 만큼 for문 돌리면서 dict값 뺴주기
for i in discount[index:index+10]:
if i not in new_dict:
break
new_dict[i]-=1
if new_dict[i] == 0:
del new_dict[i]
#최종적으로 원하는 것을 다 구입했을때 answer증감
if len(new_dict) == 0:
answer+=1
#또 다음날부터 10일차 를 구하기 위해 index 증감
index+=1
print(answer)
return answer
solution(["banana", "apple", "rice", "pork", "pot"],
[3, 2, 2, 2, 1],
["chicken", "apple", "apple", "banana", "rice", "apple", "pork", "banana", "pork", "rice", "pot", "banana", "apple", "banana"])