【在 S*******s 的大作中提到】 : u only reserve 前n个in each merge. r u sure those in the rest n won't be : promoted to front n combining with i+1 stone?
S*s
7 楼
still not convincing. say, why keep the front 1/2, instead of 1/4? i can see you tried to use some idea from dynamic planning. a good direction . however, to keep n in the queue is still expensive, anyway to get off more weight?
【在 S*******s 的大作中提到】 : still not convincing. say, why keep the front 1/2, instead of 1/4? : i can see you tried to use some idea from dynamic planning. a good direction : . however, to keep n in the queue is still expensive, anyway to get off more : weight?
Set = { 0(all) stone weight} for (int i=1; i{ get the ith smallest(largest) weight of the set; add(remove) one stone to(from) this weight, there are less than m new weights; add these weights to the set; } the nth smallest(largest) weigh of all combination is the same as the nth smallest(largest) weight of the set.
b*e
14 楼
You want to sort it because in each pass, you can do a merging easily to get n smallest out of two *sorted* n length list. Otherwise, it's a hassle. Of course, once you sort it, whichever stone you add first it not important.