CODEVS 1098 (greedy)