프로그래머스
프로그래머스 pccp 모의고사 2-3 카페확장
콩순이냉장고
2024. 12. 1. 16:52
문제 URL : https://school.programmers.co.kr/learn/courses/15009/lessons/121689
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
문제 접근법:
처음 누적합을 이용해서 풀었는데 안되서
50점까지만 맞더군요 잘안되서
q를 이용해서 완전히 시뮬레이션 하는 방식으로
문제를 풀더니 맞더군요
소스코드:
from collections import deque
def solution(menu, order, k):
res = 0
q = deque()
idx = 0
finish = k*(len(order))
t = 0
while t<=finish and idx<len(order):
if q:
q[0]-=1
if q[0]==0:
q.popleft()
if t%k==0:
q.append(menu[order[idx]])
idx+=1
res = max(res,len(q))
t+=1
return res