Pagini recente » Cod sursa (job #1400799) | Cod sursa (job #2630017) | Cod sursa (job #2669722) | Cod sursa (job #2319042) | Cod sursa (job #2715406)
input = open("energii.in", "r")
output = open("energii.out","w")
n = int(input.readline())
w = int(input.readline())
cost = [50000001]*(w+1)
for i in range(0,n):
x = input.readline().replace("\n","").split(" ")
x[0]=int(x[0])
x[1]=int(x[1])
for j in range(w, x[0], -1):
cost[j] = min(cost[j], cost[j - x[0]] + x[1])
for j in range(1,x[0]+1):
cost[j] = min(cost[j], x[1])
if cost[w] == 50000001 :
output.write("-1")
else:
output.write(str(cost[w]))
input.close()
output.close()