Python Hard
\nclass Solution:\n    def maximumSumQueries(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:\n        \'\'\'\n\n        has to
```\nclass Solution:\n    def maximumSumQueries(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:\n        \'\'\'\n\n        has to satisfy two constraints\n\n        sort by 1 \n\n\n        given x = 3 and y = 3\n\n        x = 2 and y = 2 would never be used\n\n        what does this mean?\n\n        it means that for an option x_i, y_i in arr\n\n        if there exists some pair x_j, y_j in s such that x_j >= x_i and y_j >= y_i\n\n        we dont need to add it\n        \'\'\'\n        N = len(nums1)\n\n        s = set()\n\n        arr = list(zip(nums1, nums2))\n\n        arr.sort(key=lambda x: (x[0], -x[1]))\n\n        lookup_x = set()\n\n        nxt = []\n\n        for x_i, y_i in arr:\n            if x_i in lookup_x:\n                continue\n            lookup_x.add(x_i)\n            nxt.append((x_i, y_i))\n\n        arr = nxt.copy()\n        arr.sort(key=lambda x: (x[1], -x[0]))\n        nxt = []\n        lookup_y = set()\n\n        for x_i, y_i in arr:\n            if y_i in lookup_y:\n                continue\n            lookup_y.add(y_i)\n            nxt.append((x_i, y_i))\n\n        arr = nxt.copy()\n\n        ans = []\n\n        s = sorted(arr, key=lambda x: -sum(x))\n        \n        for x, y in queries:\n\n            best = -1\n            for x_j, y_j in s:\n                if x <= x_j and y <= y_j:\n                    best = x_j + y_j\n                    break\n                    \n\n            ans.append(best)\n\n        return ans\n\n       \n        \n\n                \n\n        \n```
['Python3']