Created
August 3, 2012 00:54
-
-
Save emptysmile/3242814 to your computer and use it in GitHub Desktop.
Google Jam in Python: Store Credit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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