Last active
December 27, 2015 03:06
-
-
Save whatalnk/58719a0de09c04e48ef9 to your computer and use it in GitHub Desktop.
TopCoder SRM 676 Div2
This file contains 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
from collections import deque | |
class FarmvilleDiv2: | |
def minTime(self, time, cost, budget): | |
n = len(time) | |
time_sum = sum(time) | |
time_cost = deque(sorted([(a, b) for (a, b) in zip(time, cost)], key=lambda tup: tup[1])) | |
for i in range(n): | |
t, c = time_cost.popleft() | |
a = min(t, budget/c) | |
time_sum -= a | |
budget -= a * c | |
return(time_sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment