Intuition to solve the problem with Binary Search
First of all, this is a really hard problem so don't be depressed if you cannot solve it by yourself or cannot understand the solution immediately. Been there a
First of all, this is a really hard problem so don't be depressed if you cannot solve it by yourself or cannot understand the solution immediately. Been there and done that :) 

# Intuition
Since the time constraint is 10^5, the solution's time complexity should be bounded by O(NlogN).

In this problem to achieve this performance we have to use Binary Search.

There are 3 constraints in this problem we need to satisfy: 
- selecting the max sum of nums1[j] + nums2[j]
- nums1[j] >= x
- nums2[j] >= y 
with (x, y) is from queries. Keep that in mind, we will try to manage all these constraints in the approach.

# Approach
- First of all, we sort the queries and the pair-wise elements of nums1 and nums2 descendently by value from nums1.
**Why do we need to do that?**
By sorting in this way, we can satisfy the first contraint that requires `nums1[j] >= x`. **How?** Simply loop through the pair-wise list, and choose all the pairs that have `nums1[j] >= x`, ignore the rest. Since the queries are also sorted descendently, we don't need to worry that we ignore the valid `(nums1[j], nums2[j])` pair.

- Secondly, maintaining a stack of pair `(nums2[j], nums1[j] + nums2[j])`. The stack should be monotonic increasing by `nums2[j]` and decreasing by `nums1[j] + nums2[j]`. 
**Why do we need to do that?** There are 2 reasons:
    - We need to keep a stack monotonic increase by `nums2[j]` so that later we can apply Binary search on it to satisfy the constraint that `nums2[j] >= y`.
    - We need to keep a stack monotonic decrease by `nums1[j] + nums2[j]` to satisfy the final constraint that we should choose the `maximum sum`. 


**Note:** In my implement, I sort the pair-wise elements of nums1 and nums2 ascendently to utilize the `list.pop()` function in O(1). Yet if you want to sort descendingly, you can use `deque.popleft()`.

# Complexity
- Time complexity: O(NLogN)

# Code
```python3 []

class Solution:
    def maximumSumQueries(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:
      N = len(nums1)
      xy = sorted([(x, y) for x, y in zip(nums1, nums2)])
      qs = sorted([(*q, i) for i, q in enumerate(queries)], key=lambda x: -x[0])
      stack = []
      ans = [-1] * len(qs)
      for x, y, i in qs:
        while xy and xy[-1][0] >= x:
          x2, y2 = xy.pop()
          while stack and stack[-1][1] < x2 + y2:
            stack.pop()
          if not stack or stack[-1][0] < y2:
            stack.append((y2, x2 + y2))
        idx = bisect.bisect_left(stack, (y, 0))
        if idx != len(stack):
          ans[i] = stack[idx][1]
      return ans
```
['Python3']