Map
We first sort both queries and points by x, decreasing.\n\nAs we process queries in the decreasing order of x, we add qualified points (such as nums1[i] >= x) i
We first sort both queries and points by `x`, decreasing.\n\nAs we process queries in the decreasing order of `x`, we add qualified points (such as `nums1[i] >= x`) into map `m`.\n\nAs we insert new qualified point `{y, x + y}` into the map, we also need to remove all points to the left with smaller value `{x + y}`.\n\nTo answer a query, we just need to search our map for the same or larger `y`.\n\n**C++**\n```cpp\nvector<int> maximumSumQueries(vector<int>& nums1, vector<int>& nums2, vector<vector<int>>& queries) {\n    vector<int> nids(nums1.size()), qids(queries.size()), res(queries.size(), -1);\n    iota(begin(nids), end(nids), 0);\n    iota(begin(qids), end(qids), 0);    \n    sort(begin(nids), end(nids), [&](int i, int j){ return nums1[i] > nums1[j]; });\n    sort(begin(qids), end(qids), [&](int i, int j){ return queries[i][0] > queries[j][0]; });\n    map<int, int> m;\n    int nid = 0;\n    for (int qid : qids) {\n        int xi = queries[qid][0], yi = queries[qid][1];\n        while(nid < nids.size() && nums1[nids[nid]] >= xi) {\n            int x = nums1[nids[nid]], y = nums2[nids[nid]];\n            auto it = m.upper_bound(y);\n            if (it == end(m) || it->second < x + y) {\n                it = m.insert({y, x + y}).first;\n                while (it != begin(m) && prev(it)->second <= x + y)\n                    m.erase(prev(it));\n            }\n            ++nid;\n        }\n        if (auto it = m.lower_bound(yi); it != end(m))\n            res[qid] = it->second;\n    }\n    return res;\n}\n```
['C']