Java PriorityQueue || Simple Solution
upvote if you learn something new :)\n\nclass Solution {\n    \n    record Pair(int idx, int val){}\n    \n    public long[] unmarkedSumArray(int[] nums, int[][
upvote if you learn something new :)\n```\nclass Solution {\n    \n    record Pair(int idx, int val){}\n    \n    public long[] unmarkedSumArray(int[] nums, int[][] queries) {\n        int n = nums.length;\n        int m = queries.length;\n        long[] ans = new long[m];\n        int j = 0;\n\n        PriorityQueue<Pair> pq = new PriorityQueue<>((a,b)->a.val==b.val? a.idx-b.idx : a.val-b.val);\n        long sum = 0;\n        \n        \n        for(int i=0; i<n; i++){\n            sum += nums[i];\n            pq.add(new Pair(i,nums[i]));\n        }\n        \n        for(int[] q : queries){\n            int i = q[0];\n            int k = q[1];\n            \n            sum -= nums[i];\n            nums[i] = 0;\n            \n            \n            while(!pq.isEmpty() && k!=0){\n                Pair top = pq.poll();\n                int index = top.idx;\n                int value = top.val;\n                \n                if(nums[index]!=0){\n                    sum -= nums[index];\n                    nums[index] = 0;\n                    k--;\n                }\n                \n            }\n            ans[j++] = sum;\n        }\n        \n        \n        return ans;\n    }\n} \n```
['Heap (Priority Queue)', 'Java']