Skip to content

Instantly share code, notes, and snippets.

@calebrob6
Last active December 25, 2015 18:19
Show Gist options
  • Save calebrob6/7019587 to your computer and use it in GitHub Desktop.
Save calebrob6/7019587 to your computer and use it in GitHub Desktop.
f=open("6219.txt","r")
line=f.readline().strip()
while line!="0 0.00":
line = line.split(" ")
n = int(line[0])
money = int(float(line[1])*100)
vals = []
for i in range(n):
nextLine = f.readline().strip().split(" ")
vals.append((int(nextLine[0]),int(float(nextLine[1])*100)))
V = [0 for j in range(money+1)]
#print n,money,vals
for w in range(money+1):
currentMax = 0
for i in range(n):
if vals[i][1] <= w:
if vals[i][0] + V[w-vals[i][1]] > currentMax:
currentMax = vals[i][0] + V[w-vals[i][1]]
V[w] = currentMax
print V[money]
line = f.readline().strip()
2 8.00
700 7.00
199 2.00
3 8.00
700 7.00
299 3.00
499 5.00
0 0.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment