Just cant understand why this question is marked medium
\n\n# Complexity\n- Time complexity:O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) 
\n\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#define ll long long \nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& happiness, int k) {\n        sort(happiness.begin(),happiness.end(),greater<int>());\n         int j=0;\n         ll ans=0;\n        for(int i=0;i<k;i++){\n\n          ans+=((happiness[j]>=i)?(happiness[j]-i):0);\n          j++;\n        }\n\n        return ans;\n    }\n};\n```
['Sorting', 'Heap (Priority Queue)', 'C++']