simple upper bound binary search approach
Code\ncpp []\nclass Solution {\npublic:\n    vector<int> maximumBeauty(vector<vector<int>>& items, vector<int>& queries) {\n        sort(items.begin(),items.end
# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> maximumBeauty(vector<vector<int>>& items, vector<int>& queries) {\n        sort(items.begin(),items.end());\n        vector<int>ans;\n        int maxi=INT_MIN;\n        for(auto & x:items){\n            if(x[1]>maxi)  maxi=x[1];\n            else x[1]=maxi;\n        }\n        // for(int i=items.size()-2;i>=0;i--){\n        // if(items[i+1][0]!=items[i][0]) continue;\n        // items[i][1]=max(items[i][1],items[i+1][1]);\n        // }\n        // for(auto x:items) cout<<x[0]<<","<<x[1]<<" ";\n        for(int i=0;i<queries.size();i++){\n           if(items[0][0]>queries[i]){\n            ans.push_back(0);\n            continue;\n           }\n           else{\n           int start=0,end=items.size();\n           while(start<end){\n            int mid=start+(end-start)/2;\n            if(items[mid][0]<=queries[i]) start=mid+1;\n            else end=mid;\n           }\n             ans.push_back(items[end-1][1]);\n           }\n        }\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'Sorting', 'C++']