C++ monotonic vector solution
\n# Code\n\nclass Solution {\npublic:\n    vector<int> maximumSumQueries(vector<int>& nums1, vector<int>& nums2, vector<vector<int>>& queries) {\n        vector
\n# Code\n```\nclass Solution {\npublic:\n    vector<int> maximumSumQueries(vector<int>& nums1, vector<int>& nums2, vector<vector<int>>& queries) {\n        vector<int> ret;\n        vector<pair<int,int>> nums;\n        for(int i=0;i<nums1.size();i++)\n            nums.push_back(make_pair(nums1[i],nums2[i]));\n        sort(nums.begin(),nums.end());\n        for(int i=nums.size()-2;i>=0;i--)\n            if(nums[i].second<=nums[i+1].second)\n                nums.erase(nums.begin()+i);\n        for(auto q:queries)\n        {\n            int smax = -1;\n            for(int i=nums.size()-1;i>=0;i--)\n            {\n                if(nums[i].first<q[0])\n                    break;\n                if(nums[i].second<q[1])\n                    continue;\n                smax = max(smax, nums[i].first+nums[i].second);\n            }\n            ret.push_back(smax);\n        }\n        return ret;\n    }\n};\n```
['C++']