Simple C++ Solution with Map
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\no(n)\n\n# Code\n```\nusing intl = long long int;\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int> &nums)\n{\n    map<intl, intl> mp;\n    for (int i = 0; i < nums.size(); i++)\n    {\n        mp[nums[i]]++;\n    }\n    sort(nums.begin(), nums.end());\n    intl count = 0;\n    for (int i = 0; i < nums.size(); i++)\n    {\n        for (auto &x : mp)\n        {\n\n            while (x.first > nums[i] && i < nums.size() && x.second > 0)\n            {\n                x.second--;\n                count++;\n                i++;\n            }\n        }\n    }\n    return count;\n}\n};\n```
['C++']