[Java] Priority Queue and Priority Queue
\nclass Solution {\n        public long[] unmarkedSumArray(int[] nums, int[][] queries) {\n\t\t\n            int n = nums.length;\n            HashMap<Integer, 
```\nclass Solution {\n        public long[] unmarkedSumArray(int[] nums, int[][] queries) {\n\t\t\n            int n = nums.length;\n            HashMap<Integer, PriorityQueue<Integer>> mapa = new HashMap<>();\n            boolean[] marked = new boolean[n];\n            PriorityQueue<Integer> pq = new PriorityQueue<>();\n            long overall = 0;\n\t\t\t\n            for (int i = 0; i < n; i++) {\n                mapa.putIfAbsent(nums[i], new PriorityQueue<>());\n                mapa.get(nums[i]).add(i);\n                overall += nums[i];\n            }\n\t\t\t\n            for (int key : mapa.keySet()) {\n                pq.add(key);\n            }\n\t\t\t\n            long[] ans = new long[queries.length];\n            int pos = 0;\n            for (int[] curr : queries) {\n                int idx = curr[0], num = curr[1];\n\n                if (!marked[idx]) {\n                    overall -= nums[idx];\n                    marked[idx] = true;\n                }\n\n                while (!pq.isEmpty() && num > 0) {\n                    int head = pq.poll();\n                    PriorityQueue<Integer> lst = mapa.get(head);\n                    while (num > 0 && !lst.isEmpty()) {\n                        int id = lst.poll();\n                        if (!marked[id]) {\n                            overall -= nums[id];\n                            marked[id] = true;\n                            num--;\n                        }\n                    }\n                    if (lst.isEmpty()) {\n                        mapa.remove(head);\n                    }\n                    else {\n                        pq.add(head);\n                    }\n                }\n                ans[pos++] = overall;\n            }\n            return ans;\n        }\n    }\n\t```
[]