728x90
나의 풀이
from functools import reduce
import heapq
def solution(n, works):
if sum(works) <= n:
return 0
works = [-x for x in works]
heapq.heapify(works)
for _ in range(n):
heapq.heappush(works, heapq.heappop(works) + 1)
return reduce(lambda x, y : x + y ** 2, works, 0)
반응형
'Coding Test > Programmers' 카테고리의 다른 글
[프로그래머스/파이썬] 기지국 설치 (0) | 2022.09.21 |
---|---|
[프로그래머스/파이썬] 최고의 집합 (1) | 2022.09.21 |
[프로그래머스/MySQL] 오랜 기간 보호한 동물(2) (0) | 2022.06.23 |
[프로그래머스/MySQL] DATETIME에서 DATE로 형 변환 (0) | 2022.06.23 |
[프로그래머스/MySQL] 중서화 여부 파악하기 (0) | 2022.06.22 |