코딩테스트 고득점 Kit - 스택/큐 1 (Level 2)

 

https://programmers.co.kr/learn/courses/30/lessons/42586


Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from math import ceil

def solution(progresses, speeds):
    answer = []

    n_days = [ceil((100-p)/s) for p, s in zip(progresses, speeds)]
    pivot = n_days[0]
    tmp = 1
    for i in range(1, len(n_days)):
        print(n_days[i], pivot)
        if n_days[i] > pivot:
            pivot = n_days[i]
            answer.append(tmp)
            tmp = 0
        tmp += 1
    answer.append(tmp)

    return answer

Complexity

$O(n)$

  • $n$ = len(progresses)