Simple Java || ( with meme (a little personal))
Code\njava []\nclass Solution {\n\n    public class Comp implements Comparator<Integer[]>{\n        @Override\n        public int compare(Integer[] a,Integer[] 
# Code\n```java []\nclass Solution {\n\n    public class Comp implements Comparator<Integer[]>{\n        @Override\n        public int compare(Integer[] a,Integer[] b){\n            return a[1] - b[1] == 0 ? a[0] - b[0] : a[1] - b[1];\n        }\n    }\n\n    public long[] unmarkedSumArray(int[] nums, int[][] queries) {\n        PriorityQueue<Integer[]> minHeap = new PriorityQueue<Integer[]>(new Comp());\n        long[] res = new long[queries.length];\n        long total = 0;\n        int k = 0;\n\n        for(int num:nums){\n            total = total + num;\n            minHeap.add(new Integer[]{k++,num});\n        }\n        k=0;\n        for(int[] query:queries){\n            int index = query[0];\n            int min = query[1];\n\n            if(nums[index] != -1){\n                total = total - nums[index];\n                nums[index] = -1;\n            }\n\n            while(min>0 && !minHeap.isEmpty()){\n                Integer[] el = minHeap.poll();\n                int indexMin = el[0];\n                if(nums[indexMin] != -1){\n                    total = total - nums[indexMin];\n                    nums[indexMin] = -1;\n                    min--;\n                }\n            }\n            res[k++] = total; \n        }\n\n        return res;\n    }\n}\n```\n\n![image.png](https://assets.leetcode.com/users/images/e3c01689-2829-4b9c-aee9-d48aa8ba9db2_1724355527.0233874.png)\n
['Java']