二進タプルを述べる順序付けと最適化アルゴリズム

今日トップコーダーの五百点の問題を結局解けました。秘められた正解は二進タプルを全て見る事でした。問題に定義された「歌」の行列から複数の件を選択してこの合計の「時間」と「トーン差」を計算する事が必要でした。選択された数が一番多くて総時間が定義された「T」より低いか同じ行列の長さが出力変数でした。
The challenge of this algorithm was to map subset selections from a list of 15 or fewer elements to binary n-tuples (where a 1 in the ith position meant that the ith element in the list was chosen). For 15 elements, there are 32768 tuples (0-32767). For each selection, the durations of the songs are determined, but the tone discrepancy between consecutive songs depends on the order of the list. Thus, the songs are sorted to make the tones monotonically increasing. In order to compute the time needed for the list, each song's duration is added, and then, if i>0, |tone[sel[i]]-tone[sel[i-1]]| is added, where sel[i] is the ith element in the selection. My error was to use tone[i], causing the time calculation to succeed only if the indices 0,1,...len-1 agreed with the selection indices.
Another mistake was the failure to remove the leftmost bit of the bitmap after adding the selection to the list in the bitmap->selection transformation. This was achieved by bitMap = bitMap%(1<