문제
코드
from math import ceil
def solution(progresses: list, speeds: list) -> list:
stack, answer = [], []
baepo_day = [ceil((100-progresses[x]) / speeds[x]) for x in range(len(progresses))]
for x in baepo_day:
if not stack:
stack.append(x)
continue
if stack[0] < x:
answer.append(len(stack))
stack = [x]
else:
stack.append(x)
answer.append(len(stack))
return answer
if __name__ == '__main__':
print(solution([93, 30, 55], [1, 30, 5]))
print(solution([95, 90, 99, 99, 80, 99], [1, 1, 1, 1, 1, 1]))
print(solution([99, 99, 99, 90, 90, 90], [1, 1, 1, 1, 1, 1]))
print(solution([40, 93, 30, 55, 60, 65], [60, 1, 30, 5, 10, 7]))
print(solution([93, 30, 55, 60, 40, 65], [1, 30, 5, 10, 60, 7]))
결과
출처 & 깃허브
programmers 기능개발
github