activity selection problem dynamic programming pseudocode