Finding a single subset with a given weight is
NP hard. If you've some way to identify all the
subsets of a given weight and whose costs are less
than $300 then you need to solve an exact cover
problem, which is NP hard in general. So you can't
expect to find any algorithm with less than
exponential complexity in the worst case.

But what I'd try here is this:

```
let W = total weight of all packages
let N = total number of packages
for k = 1, 2, 3, ..., N
find all subsets of packages with weight W/k
and cost less than $300
if there's an exact cover: stop with solution.
```

You can find subsets of the right weight and
cost using dynamic programming assuming the number
of different weights and costs are small enough.
You can find exact covers using the dancing links
algorithm.