야근 지수
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
- 내 풀이
- n<= 1,000,000
- ➡ heapq 사용
- queue가 비어있는지 확인 안하면 런타임에러!!
- n<= 1,000,000
import heapq
def solution(n, works):
#피로도: 시작 시점+(남은일의 작업량)**2
answer = 0
queue=[]
for work in works:
heapq.heappush(queue,-work)
while n>=1:
if not queue:
break
tmp=heapq.heappop(queue)
if tmp!=0:
heapq.heappush(queue, tmp+1)
n-=1
for q in queue:
if q==0:
continue
answer+=q**2
return answer
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
| [프로그래머스][DP] 등굣길 (0) | 2024.11.01 |
|---|---|
| [프로그래머스][백트래킹] 단어 변환 (0) | 2024.11.01 |
| [프로그래머스][스택] 택배상자 (0) | 2024.10.31 |
| [프로그래머스][스택] 뒤에 있는 큰 수 (0) | 2024.10.30 |
| [프로그래머스] 롤케이크 자르기 (0) | 2024.10.30 |