🔢Easy python solution using Heap(Priority Queue) and set
Intuition\nWe can efficiently process each query by maintaining a min heap of unmarked elements along with their indices. On each query, we mark the queried ind
# Intuition\nWe can efficiently process each query by maintaining a min heap of unmarked elements along with their indices. On each query, we mark the queried index if it is not already marked and then pop the smallest unmarked elements from the heap, marking them as well until we reach the required number of elements to mark. We keep track of the sum of unmarked elements throughout the process.\n\n# Approach\n1. Create a min heap to store unmarked elements along with their indices. Initialize the total sum of unmarked elements.\n2. Iterate through the array and push each element along with its index onto the heap.\n3. Iterate through each query. If the queried index is not already marked, mark it and subtract its value from the total sum.\n4. Pop elements from the heap while there are still unmarked elements to mark and the required number of elements to mark is greater than zero. If the popped element\'s index is not already marked, subtract its value from the total sum and mark its index. Decrement the required number of elements to mark.\n5. Append the current total sum to the output array.\n6. Return the output array.\n \n# Complexity\n**- Time complexity:**\nThe time complexity is O((n + m) log n), where n is the size of the input array and m is the number of queries. This complexity arises from the heap operations and iterating through the array and queries.\n\n**- Space complexity:**\nThe space complexity is O(n) to store the heap and additional data structures.\n\n \n# Code\n```py\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        heap = []\n        for i in range(len(nums)) : \n            heappush(heap, (nums[i], i))\n\n        total = sum(nums)\n\n        output, marked = [], set()\n        for index, k in queries : \n            if index not in marked :\n                marked.add(index)\n                total -= nums[index] \n                \n            while k != 0 and heap : \n                num, index = heappop(heap)\n                if index not in marked :\n                    total -= num \n                    k -= 1\n                    marked.add(index)\n            output.append(total)\n\n        return output\n```
['Array', 'Hash Table', 'Sorting', 'Heap (Priority Queue)', 'Simulation', 'Python', 'Python3']