Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TopCoder SRM 670
class Cdgame():
def rescount(self, a, b):
sum_a = sum(a)
sum_b = sum(b)
res = []
for i in a:
for j in b:
class Drbalance():
def lesscng(self, s, k):
l = list(s)
res = 0
while True:
costs = [l.count("+") - l.count("-")]
for i in range(len(l)):
ll = l[:-i]
costs.append(ll.count("+") - ll.count("-"))
costs_sum = len([i for i in costs if i < 0])
if costs_sum > k:
i = l.index("-")
l[i] = "+"
res += 1
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.