Skip to content

Commit cfbda22

Browse files
committed
[PGS] 야근 지수 / Level3 / 40분
1 parent fb42682 commit cfbda22

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import heapq
2+
def solution(n, works):
3+
# n: 남은 시간
4+
# works: 각 일에 대한 작업량을 나타낸 array
5+
# 야근피로도 = 야근 시작 시점에서 남은 일의 작업량을 제곱해서 더한것
6+
# works의 길이가 20,000 미만이니까.. O(n**2)까지도 Okay..?
7+
# 매번 정렬해야지 생각하고도 heap을 떠올리지못한 나를 탓하라.
8+
answer = 0
9+
works2 = [-w for w in works]
10+
heapq.heapify(works2)
11+
12+
while n > 0:
13+
value = heapq.heappop(works2)
14+
if value != 0:
15+
value += 1
16+
n -= 1
17+
heapq.heappush(works2, value)
18+
19+
answer = sum([(w * -1) ** 2 for w in works2])
20+
return answer

0 commit comments

Comments
 (0)