easy heap and map solution (keep track of indices)
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public long[] unmarkedSumArray(int[] nums, int[][] queries) {
        long sum = 0;
        Map<Integer, Integer> map = new HashMap<>();

        PriorityQueue<Integer> heap = new PriorityQueue<>((a, b) -> {
            int comp = Integer.compare(map.get(a), map.get(b));
            if (comp != 0) return comp;

            return Integer.compare(a, b);
        });

        int n = nums.length;
        for (int i = 0; i < n; i++) {
            int num = nums[i];
            sum += num;

            map.put(i, num);
            heap.add(i);
        }

        Set<Integer> seen = new HashSet<>();
        n = queries.length;  
        long[] arr = new long[n];

        for (int i = 0; i < n; i++) {
            int index = queries[i][0];
            int k = queries[i][1];

            if (!seen.contains(index)) {
                sum -= map.get(index);
                seen.add(index);
            }

            while (heap.size() > 0 && k > 0) {
                int j = heap.remove();

                if (!seen.contains(j)) {
                    sum -= map.get(j);
                    seen.add(j);
                    k--;
                }
            }

            arr[i] = sum;
        }

        return arr;
    }
}
```
['Array', 'Hash Table', 'Heap (Priority Queue)', 'Java']