Skip to content

Instantly share code, notes, and snippets.

@niklasb
Created April 19, 2012 01:43
Show Gist options
  • Save niklasb/2417788 to your computer and use it in GitHub Desktop.
Save niklasb/2417788 to your computer and use it in GitHub Desktop.
Codejam 2012 - Dancing with the Googlers
def acc(p, total):
best, rest = divmod(total + 2, 3)
return (1, 0) if best >= p else (0, total and rest and best + 1 == p)
for i, line in enumerate(input() for _ in range(int(input()))):
_, S, p, *totals = map(int, line.split())
a, s = map(sum, zip(*(acc(p, total) for total in totals)))
print("Case #%d: %d" % (i + 1, a + min(s, S)))
@niklasb
Copy link
Author

niklasb commented Apr 19, 2012

@MartinThoma: check revision 036d17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment