correct but too slow at O(n^2); could be faster with segment tree implementation
easiest greedy problem ever - solved in under 20 minutes