Is this variant of the subset sum problem easier to solve?

后端 未结 8 848
旧巷少年郎
旧巷少年郎 2020-12-08 23:18

I have a problem related to the subset sum problem and am wondering if the differences make it easier, i.e. solvable in a reasonable amount of time.

Given a value V,

8条回答
  •  醉话见心
    2020-12-09 00:08

    One optimization that comes to mind is this: Order your sequence (if it alerady isn't so). Pick the first L-1 items from the start of it, and then pick the last item such, that it's the largest possible value (the next largest value in the sequence would give a sum too big). Discard the rest of the sequence, because those items can never be a part of a valid subset anyway.

    After that I guess it's full search again. But then again there might be other optimiziations possible too.

提交回复
热议问题