class Solution:

def getOrder(self, tasks: List[List[int]]) -> List[int]:
start_q = [tasks[i] + [i] for i in range(len(tasks))]
heapify(start_q)
start, time, idx = heappop(start_q)
time_q = [[time, idx, start]]
ans = []
cur = start
while len(time_q):
time, idx, start = heappop(time_q)
cur = cur + time
ans.append(idx)
while len(start_q) and start_q[0][0] <= cur:
start, time, idx = heappop(start_q)
heappush(time_q, [time, idx, start])
if len(time_q) == 0 and len(start_q):
start, time, idx = heappop(start_q)
cur = start
heappush(time_q, [time, idx, start])

return ans


일단 시작시간 순으로 정렬한 start_q

그리고 실행시간에 대한 최소 힙인 time_q -> 여기서 순서를 줘서 인덱스도 처리가능


그래서 start_q에서 현재 시간 cur에 실행가능한 애를 time_q로 넣고

time_q에서 짧게 걸리는 애를 답에 넣어주면서 cur를 갱신함

난 종료 조건을 time_q가 비는 걸로 해서 time_q가 비고 start_q가 안 비면 time_q에 넣어주는 예외 처리를 했음