디스크 컨드롤러 - python(programmers)

참치돌고래·2021년 9월 6일
0

알고리즘

목록 보기
25/36
post-custom-banner

https://programmers.co.kr/learn/courses/30/lessons/42627#


def solution(jobs):
    answer = 0
    jobs.sort(key= lambda x : x[1])
    
    job_length = len(jobs)
    
    time = 0
    
    
    while True:
        for idx, job in enumerate(jobs):
            start = job[0]
            length = job[1]
            if start <= time:
                
                answer += length + time - start
                time += length
                
                del jobs[idx]
                break
        else:
            
            time +=1
        
        if len(jobs) ==0:
            break
        
                
    
        
            
        
    return answer//job_length
profile
안녕하세요
post-custom-banner

0개의 댓글