Python (Simple BIT)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass BIT:\n    def __init__(self, n):\n        self.ans = [0]*(n+1)\n\n    def update(self, i, val):\n        while i < len(self.ans):\n            self.ans[i] += val \n            i += i&-i\n\n    def query(self, i):\n        total = 0 \n\n        while i > 0:\n            total += self.ans[i]\n            i -= i&-i\n\n        return total \n\nclass Solution:\n    def maxRemoval(self, nums, queries):\n        n, i, ans, total = len(nums), 0, [], len(queries)\n\n        queries.sort()\n        \n        fenwick_tree = BIT(n)\n\n        for j in range(n):\n            while i < len(queries) and queries[i][0] <= j:\n                heapq.heappush(ans,(-queries[i][1],queries[i][0]))\n                i += 1 \n\n            while nums[j] - fenwick_tree.query(j+1) > 0 and ans:\n                total -= 1 \n                x = heapq.heappop(ans)\n                fenwick_tree.update(x[1]+1,1)\n                fenwick_tree.update(-x[0]+2,-1)\n\n            if nums[j] - fenwick_tree.query(j+1) > 0:\n                return -1\n\n        return total \n```
['Python3']