[Python] 4-lines Solution
Explanation\nStep 1. Sort the items by price, O(nlog)\nStep 2. Iterate items, find maximum value up to now, O(n)\nStep 3. For each queries, binary search the ma
# **Explanation**\nStep 1. Sort the items by price, `O(nlog)`\nStep 2. Iterate items, find maximum value up to now, `O(n)`\nStep 3. For each queries, binary search the maximum `beauty`, `O(qlog)`\nStep 3 can be doen in `O(q+n)` though.\n<br>\n\n# **Complexity**\nTime `O(nlogn + qlogn)`\nSpace `O(n)`\n<br>\n\n\n**Python**\n```py\n    def maximumBeauty(self, A, queries):\n        A = sorted(A + [[0, 0]])\n        for i in xrange(len(A) - 1):\n            A[i + 1][1] = max(A[i][1], A[i + 1][1])\n        return [A[bisect.bisect(A, [q + 1]) - 1][1] for q in queries]\n```\n
[]