SRM 472 Greedy algorithm.