activity select ruby code implementation about greedy algorithm