Pagini recente » Cod sursa (job #2921677) | Cod sursa (job #909264) | Cod sursa (job #3251904) | Cod sursa (job #1873623) | Cod sursa (job #2715471)
def main ():
input = open("energii.in", "r")
output = open("energii.out","w")
toInt = lambda a : [int(a[0]), int(a[1])]
n, w = int(input.readline()), int(input.readline())
cost = [50000001]*(w+1)
for i in range(0,n):
x = toInt(input.readline().split(" "))
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])
output.write("-1") if cost[w] == 50000001 else output.write(str(cost[w]))
input.close()
output.close()
main()