Created
March 15, 2014 21:06
-
-
Save chipbell4/9573916 to your computer and use it in GitHub Desktop.
My Solution For Queen Dido
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
def max_area(L): | |
L.sort() | |
left, right = 0,0 | |
while len(L) > 0: | |
# if the left is shorter, put the twig over there | |
if left < right: | |
left += L.pop() | |
# if the right is shorter, put it on the right | |
else: | |
right += L.pop() | |
return left * right // 2 | |
while True: | |
try: | |
# read the input, ignoring the first (the number of cases) | |
twigs = list(map(int, input().strip().split())) | |
twig_count = twigs[0] | |
twigs = twigs[1:twig_count + 1] | |
print( max_area(twigs) ) | |
except EOFError: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment