diff --git a/kjs254/README.md b/kjs254/README.md index d8df057..620af80 100644 --- a/kjs254/README.md +++ b/kjs254/README.md @@ -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) | --- diff --git "a/kjs254/\355\201\220/2-kjs254" "b/kjs254/\355\201\220/\355\224\204\353\241\234\354\204\270\354\212\244.py" similarity index 100% rename from "kjs254/\355\201\220/2-kjs254" rename to "kjs254/\355\201\220/\355\224\204\353\241\234\354\204\270\354\212\244.py" diff --git "a/kjs254/\355\236\231/\354\225\274\352\267\274 \354\247\200\354\210\230.py" "b/kjs254/\355\236\231/\354\225\274\352\267\274 \354\247\200\354\210\230.py" new file mode 100644 index 0000000..74c1573 --- /dev/null +++ "b/kjs254/\355\236\231/\354\225\274\352\267\274 \354\247\200\354\210\230.py" @@ -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 \ No newline at end of file