You are viewing a single comment's thread. Return to all comments →
#python #BrokenInputFuntion def unboundedKnapsack(k, arr): temp=[0]*(k+1) for x in arr: for y in range(x, k+1): temp[y]=max(temp[y], temp[y - x] + x) return temp[k] for _ in range(int(input())): n, k=input().split() arr=list(map(int, input().split())) print(unboundedKnapsack(int(k), arr))
Seems like cookies are disabled on this browser, please enable them to open this website
Knapsack
You are viewing a single comment's thread. Return to all comments →