Created
December 13, 2019 05:27
-
-
Save inspirit941/64c9addb217ac7564ec6e3fcd1c4d8e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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