clever code, sorting, greedy

Level A