Your solution works great when is small. But what if ? You can't create an array of size . The solution crashes before it starts.
But notice something: even with huge weights, the total value might be bounded. If and each value is at most , the maximum possible value is . What if you flipped the problem? Instead of "max value for this weight," ask "min weight for this value." That's the observation for the next problem.