2021-07-26-월 문제풀기

골솔·2021년 7월 26일
0

알고문제풀기

목록 보기
19/27

프로그래머스

프린터

import heapq
def solution(priorities, location):
    answer = 0
    a = []
    for i in range(len(priorities)):
        a.append((-priorities[i], i))
        
    while True:
        b = a[:]
        heapq.heapify(b)
        if a[0][0] > b[0][0]:
            temp2 = a[0]
            a = a[1:]
            a.append(temp2)
        else:
            temp = a[0]
            answer += 1
            a = a[1:]
            if temp[1] == location:
                break
        
    return answer
profile
골때리는이솔

0개의 댓글