結果 : write the general greedy algorithm with pseudocode