Created
October 29, 2013 13:23
-
-
Save cocodrips/7214554 to your computer and use it in GitHub Desktop.
SRM588 Div2 500
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 itertools | |
class GUMIAndSongsDiv2: | |
def maxSongs(self, duration, tone, T): | |
duration_tones = [] | |
for i, d in enumerate(duration): | |
duration_tones.append((tone[i], d)) | |
duration_tones.sort() | |
n = 0 | |
for i in xrange(1, len(duration_tones) + 1): | |
for duration_tone in itertools.combinations(duration_tones, i): | |
accumulate_time = 0 | |
for index, tuple in enumerate(duration_tone): | |
accumulate_time += tuple[1] | |
if index >= 1: | |
accumulate_time += duration_tone[index][0] - duration_tone[index-1][0] | |
if accumulate_time <= T: | |
n = i | |
break | |
else: | |
break | |
return n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment