Pagini recente » Cod sursa (job #2782218) | Cod sursa (job #3293644) | Cod sursa (job #2651876) | Cod sursa (job #1155621) | Cod sursa (job #2715478)
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)
i = 0
while i<n:
x = toInt(input.readline().replace("\n","").split(" "))
j = w
while j > x[0]:
cost[j] = min(cost[j], cost[j - x[0]] + x[1])
j -= 1
j=1
while j <= x[0]:
cost[j] = min(cost[j], x[1])
j += 1
i +=1
output.write("-1") if cost[w] == 50000001 else output.write(str(cost[w]))
input.close()
output.close()
main()