topcoder recursion greedy