Sort items by value/weight ratio (descending). Take items in order until capacity runs out. For the last item that does not fully fit, take a fraction. It works because with fractions, there is no blocking.
You can always squeeze in more value by taking the highest-ratio items first. Time: . Space: .