Skip to content

Instantly share code, notes, and snippets.

@kusano
Created May 31, 2014 16:32
Show Gist options
  • Save kusano/2d7f54be9b80d1da9b1f to your computer and use it in GitHub Desktop.
Save kusano/2d7f54be9b80d1da9b1f to your computer and use it in GitHub Desktop.
Google Code Jam 2014 Round 2 A Data Packing
for test in range(input()):
N, X = map(int, raw_input().split())
S = map(int, raw_input().split())
S.sort()
ans = 0
a, b = 0, N-1
while a<=b:
if a<b and S[a]+S[b] <= X:
a += 1
b -= 1
ans += 1
print "Case #%s: %s" % (test+1, ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment