Skip to content

Instantly share code, notes, and snippets.

@GaZ3ll3
Created April 11, 2015 17:16
Show Gist options
  • Save GaZ3ll3/dbd7cdfb7e2b67069a69 to your computer and use it in GitHub Desktop.
Save GaZ3ll3/dbd7cdfb7e2b67069a69 to your computer and use it in GitHub Desktop.
google code jam 2015 qround
import math
cases = int(raw_input())
for c in xrange(cases):
x = map(int, raw_input())
y = map(int, raw_input().split())
y = sorted(y, reverse=True)
m = y[0]
res = y[0]
for r in range(1, m + 1):
move = 0
for z in y:
if z <= r:
break
move += math.ceil(float(z) / float(r)) - 1
if move + r < res:
res = move + r
print('Case #%d: %d' % (c + 1, res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment