[Programmers 42586] 기능개발

Updated:

문제

LV2 [Programmers 42586 - 기능개발]

문제 풀이 방법

  1. 각 작업을 수행하는데 걸리는 day를 days배열에 저장한다.
  2. max 변수에 days의 첫 번째 원소를 넣고, days 배열을 순회하면서 다음 과정을 수행한다.
    1. day가 max보다 크다면 answer배열에 수행한 작업의 개수 count를 넣고, count는 1로 초기화하고, max는 day로 초기화하여 배포과정을 진행한다.
    2. max가 day보다 크다면 다음 작업과 같은 배포할 수 있으므로 수행작업 개수 count를 +1 해준다.

풀이 코드

Python

import math

def solution(progresses, speeds):
    answer = []
    days=[]
    for (i,j) in zip(progresses,speeds):
        days.append(math.ceil((100-i)/j))
    print(days)
    max=days[0]
    count=0
    for day in days:
        if day>max:
            answer.append(count)
            count=1
            max=day
        else: count+=1
    answer.append(count)
    return answer
if __name__=='__main__':
    print(solution([93, 30, 55],[1, 30, 5]))

댓글남기기