note
dragonchild
Given that definition, [belg4mit] is absolutely right - this is a 1-D knapsack. Look in any upper-level algorithms book or just google "knapsack algorithm". My algorithm would have given you the smallest number of largest individual segements without taking into account the total coverage. (It can be easily extended to that by figuring out the all the overlaps for a given new segment, then comparing the total coverage between the new segment and the old segment(s). However, I would go with the algorithm that PhD's have optimized. If you cannot figure out how to write it, I'd be glad to provide an implementation of my naive version.)
<p>------<br><i>We are the carpenters and bricklayers of the Information Age.</i><p><i>The idea is a little like C++ templates, except not quite so brain-meltingly complicated.</i> -- [TheDamian], Exegesis 6<p>Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
279587
279625