Skip to content

Instantly share code, notes, and snippets.

@niklasb
Created April 19, 2012 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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)))
@MartinThoma
Copy link

When I execute your code, I get:

moose@pc07:~/Desktop$ python ProblemA.py < /home/moose/Downloads/B-small-practice.in 
  File "ProblemA.py", line 9
    _,S, p, *totals = map(int, line.split())
            ^
SyntaxError: invalid syntax

@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