diff --git a/solutions/day14/solution_py.py b/solutions/day14/solution_py.py new file mode 100644 index 0000000..398f47c --- /dev/null +++ b/solutions/day14/solution_py.py @@ -0,0 +1,12 @@ +class Solution: + def maxKelements(self, nums: List[int], k: int) -> int: + heapify(pq:=[-x for x in nums]) + score=0 + for i in range(k): + x=-heappop(pq) + score+=x + if x==1: + score+=k-1-i + break + heappush(pq, -((x+2)//3)) + return score