2021-08-17-화 문제풀기

골솔·2021년 8월 17일
0

알고문제풀기

목록 보기
23/27

프로그래머스

디스크 컨트롤러

import heapq
def solution(jobs):
    answer = 0
    time = 0
    ready = []
    idx = 0
    jobs.sort()
    n = len(jobs)
    isReady = [False] * n
    while idx < n:
        for i in range(n):
            if (not isReady[i]) and jobs[i][0] <= time:
                heapq.heappush(ready, (jobs[i][1],jobs[i][0]))
                isReady[i] = True
        if ready:
            a, b= heapq.heappop(ready)
            time += a
            answer += time - b
            print(answer)
            idx += 1
        else:
            time +=1
    answer = answer // n
    return answer
profile
골때리는이솔

0개의 댓글