Skip to content

Commit

Permalink
Merge pull request #10 from kjs254/2-kjs254
Browse files Browse the repository at this point in the history
3-kjs254
  • Loading branch information
kjs254 authored Feb 21, 2024
2 parents 17ce3a3 + 1c2f0bf commit 3ab9e6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions kjs254/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.02.12 | μŠ€νƒ | [κΈ°λŠ₯개발](https://school.programmers.co.kr/learn/courses/30/lessons/42586) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/2) |
| 2μ°¨μ‹œ | 2024.02.15 | 큐 | [ν”„λ‘œμ„ΈμŠ€](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/6) |
| 3μ°¨μ‹œ | 2024.02.15 | νž™ | [μ•Όκ·Ό μ§€μˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/12927) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/10) |
---
File renamed without changes.
16 changes: 16 additions & 0 deletions kjs254/νž™/μ•Όκ·Ό μ§€μˆ˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import heapq
def solution(n, works):
max_heap = []
for w in works:
heapq.heappush(max_heap, (-w,w))

for i in range(n):
max_work = heapq.heappop(max_heap)[1]-1
if max_work<0:
return 0

heapq.heappush(max_heap,(-max_work,max_work))

print(max_heap)
answer = sum([x[1]**2 for x in max_heap])
return answer

0 comments on commit 3ab9e6a

Please sign in to comment.