Easiest c++ solution 87ms beats 97.95% solve by sorting
IntuitionApproachComplexity
Time complexity: O(nlgn)

Space complexity: O(n)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: $$O(nlgn)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    long long maximumHappinessSum(vector<int>& happiness, int k) {
        sort(happiness.begin(), happiness.end(), greater<int>());
        long long mx = 0;
        for(int i = 0;i < k;i++){
            if(happiness[i] - i > 0) mx += happiness[i] - i;
            else return mx;
        }
        
        return mx;
    }
};

auto init = []()
{ 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    return 'c';
}();
```
['Array', 'Greedy', 'Sorting', 'C++']