刚看到这个题目, 既然是亚麻常用提. 我来提供一个思路,看看可不可以, 这个思路绝
对能找到答案,但是不一定是复杂度最低
的.请发包子.
Let assume we have n records, and the required record number if p.
1, couple the record into sets of another structure. Lets call it aux, which
include any coupled records. Namely any ith and jth record build a aux,
totaly we can have n*(n-1) aux.
2, calculate the new weight of the each aux, if the interval of its records
has overlaps, the weight of that aux will be set as some crazy small number,
which indicts this aux is not feasible choice.
3, remove all the aux that have crazy small weight
4, build a new sets by coupling the input records and the aux we just sorted
.lets say we have q aux left, the new set of aux will be q*(n-1).
5, recursive search and sort. until the record number of aux reach the
required set number.
6, find the maximum weight from all the remaining aux structures with the
new calculated weights.
Good luck