[C++]| [Map]| [Easy Understandable]
\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        map<int,int>mp;\n        int k=0;\n        for(auto &it:nums) mp[it]++;\n  
```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        map<int,int>mp;\n        int k=0;\n        for(auto &it:nums) mp[it]++;\n        int ans=0;\n        for(int i=0;i<nums.size();i++){\n            auto it=mp.upper_bound(nums[i]);\n            if(it!=mp.end() && it->second>0){\n                ans++;\n                it->second=it->second-1;\n                if(it->second==0) mp.erase(it);\n            }\n            \n            \n        }\n        return ans;\n    }\n};\n```
['C++']