Skip to content

Instantly share code, notes, and snippets.

@inspirit941
Created December 13, 2019 05:27
Show Gist options
  • Save inspirit941/64c9addb217ac7564ec6e3fcd1c4d8e3 to your computer and use it in GitHub Desktop.
Save inspirit941/64c9addb217ac7564ec6e3fcd1c4d8e3 to your computer and use it in GitHub Desktop.
import heapq
def solution(n, works):
if sum(works) < n: return 0
works = [-i for i in works]
heapq.heapify(works)
while n > 0:
heapq.heappush(works, heapq.heappop(works) + 1)
n -= 1
return sum([i**2 for i in works])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment