Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
TopCoder SRM 669 Div2
class LiveConcert():
def maxHappiness(self, h, s):
dict = {}
m = len(h)
for (key, val) in zip(s, h):
if dict.has_key(key):
dict[key].append(val)
else:
dict[key] = [val]
happiness = 0
for val in dict.itervalues():
happiness += max(val)
return happiness
from collections import deque
class CombiningSlimes():
def maxMascots(self, a):
mascots = 0
aa = deque(sorted(a))
while len(aa) != 1:
l = aa.popleft()
r = aa.pop()
aa.append(l+r)
mascots += l*r
return(mascots)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment