Skip to content

Instantly share code, notes, and snippets.

@chipbell4
Created March 15, 2014 21:06
Show Gist options
  • Save chipbell4/9573916 to your computer and use it in GitHub Desktop.
Save chipbell4/9573916 to your computer and use it in GitHub Desktop.
My Solution For Queen Dido
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