C++ solution using the hints
Implementing the monotone map approach explained in the hints\n\nclass Solution {\npublic:\n  \n  vector<int> maximumSumQueries(vector<int>& nums1, vector<int>&
Implementing the monotone map approach explained in the hints\n```\nclass Solution {\npublic:\n  \n  vector<int> maximumSumQueries(vector<int>& nums1, vector<int>& nums2, vector<vector<int>>& queries) {\n    int n = nums1.size();\n    vector<pair<int, int>> combined;\n    for (int i = 0; i < n; ++i) {\n      combined.push_back({nums1[i], nums2[i]});\n    }\n    sort(combined.begin(), combined.end(), [] (const auto& p1, const auto& p2) {\n      return p1 > p2;\n    });\n    vector<pair<pair<int, int>, int>> qrs;\n    for (int i = 0; i < queries.size(); ++i) {\n      qrs.push_back({{queries[i][0], queries[i][1]}, i});\n    }\n    sort(qrs.begin(), qrs.end(), [](const auto& p1, const auto& p2) {\n      return p1.first > p2.first;\n    });\n    vector<int> ans(queries.size(), -1);\n    map<int, int> yToSum;\n    \n    int idx = 0;\n    for (auto& qr : qrs) {\n      auto [pr, i] = qr;\n      auto [x, y] = pr;\n      \n      while (idx < n && combined[idx].first >= x) {\n        int sum = combined[idx].first + combined[idx].second;\n        auto lb = yToSum.lower_bound(combined[idx].second);\n        if (lb == yToSum.end()) {\n          yToSum[combined[idx].second] = sum;\n          lb = --yToSum.end();\n        }\n        while (true) {\n          if (lb->first <= combined[idx].second && lb->second < sum) {\n            lb = yToSum.erase(lb);\n          }\n          if (lb == yToSum.begin()) break;\n          --lb;\n        }\n        idx++;\n      }\n      auto lb = yToSum.lower_bound(y);\n      if (lb == yToSum.end()) continue;\n      ans[i] = lb->second;\n    }\n    return ans;\n  }\n};\n```
[]