Python 3 || 16 lines, heap || T/S: 87% / 15%
\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], \n                               queries: List[List[int]]) -> List[int]:\n\n        n, sm = l
```\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], \n                               queries: List[List[int]]) -> List[int]:\n\n        n, sm = len(nums), sum(nums)\n        unmarked, ans = set(range(n)), []\n\n        heap = list(zip(nums,range(len(nums))))\n        heapify(heap)\n\n        for idx, k in queries:\n\n            if idx in unmarked:\n                sm -= nums[idx]\n                unmarked.discard(idx)\n\n            while k and heap:\n\n                num, idx = heappop(heap) \n\n                if idx in unmarked:               \n                    unmarked.discard(idx)\n                    k-= 1\n                    sm-= num\n\n            ans.append(sm)\n\n        return ans\n```\n[https://leetcode.com/problems/mark-elements-on-array-by-performing-queries/submissions/1205578480/](https://leetcode.com/problems/mark-elements-on-array-by-performing-queries/submissions/1205578480/\n)\n\n\n\nI could be wrong, but I think that time complexity is *O*(*N* log *N* + *O*(*Q* log *N*)) and space complexity is *O*(*N*), in which *N* ~ `len(nums)` and  *Q* ~ `len(queries)`.
['Python3']