[プログラマー]ディスクコントローラ(Python Python Python Python Python Python Python Python)
👉 ディスクコントローラ
マイコード
# 2레벨 코딩테스트 고득점 Kit 디스크 컨트롤러
import heapq as hq
from collections import deque
def solution(jobs):
deq = deque(sorted(jobs))
heap = []
time = 0
result = 0
while deq or heap:
if deq and deq[0][0] <= time:
t = deq.popleft()
hq.heappush(heap, (t[1], t[0]))
if heap:
t = hq.heappop(heap)
time += t[0]
result += time - t[1]
else:
time += 1
return int(result / len(jobs))
if __name__ == "__main__":
print(solution([[0, 3], [1, 9], [2, 6]]))
チップ
Reference
この問題について([プログラマー]ディスクコントローラ(Python Python Python Python Python Python Python Python)), 我々は、より多くの情報をここで見つけました https://velog.io/@coding_egg/프로그래머스-디스크-컨트롤러-python-파이썬テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol