Runtime: 264 ms, faster than 100.00% of JavaScript online submissions
\nvar maximumBeauty = function(items, queries) {\n    items.sort((a,b) => a[0]-b[0]);\n    const n = items.length;\n    \n    \n    let mx = items[0][1];\n    \
```\nvar maximumBeauty = function(items, queries) {\n    items.sort((a,b) => a[0]-b[0]);\n    const n = items.length;\n    \n    \n    let mx = items[0][1];\n    \n    for (let i = 0; i<n; i++) {\n        mx = Math.max(mx, items[i][1]);\n        items[i][1] = mx;\n    }\n    \n    \n    const ans = [];\n    \n    for (const q of queries) {\n        let l = 0, r = n-1, a = 0;\n        while (l<=r) {\n            let mid = Math.floor(l+(r-l)/2);\n            if (items[mid][0]<=q) {\n                a = items[mid][1]\n                l = mid+1;\n            } else r = mid-1;\n        }\n        ans.push(a)\n    }\n    \n    return ans;\n};\n```
['Binary Tree', 'JavaScript']