Skip to content

Instantly share code, notes, and snippets.

@emptysmile
Created August 3, 2012 00:54
Show Gist options
  • Save emptysmile/3242814 to your computer and use it in GitHub Desktop.
Save emptysmile/3242814 to your computer and use it in GitHub Desktop.
Google Jam in Python: Store Credit
read = open("./A-large-practice.in", "r")
write = open("./A-large-practice.out", "w")
totalCase = int(read.readline())
for case in xrange(totalCase):
C = int(read.readline())
I = int(read.readline())
P = list(map((lambda x:int(x)), read.readline().strip().split()))
bestChoice = 0
bestCase = []
for i in xrange(I):
for j in xrange(i+1, len(P)):
if bestChoice < P[i]+P[j] and P[i]+P[j] <= C:
del bestCase[:]
bestChoice = P[i]+P[j]
bestCase.append(i+1)
bestCase.append(j+1)
write.write("Case #%d: %d %d\n"%(case+1,bestCase[0],bestCase[1]))
read.close()
write.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment