Beats 100% || Priority Queue || Easy to Understand solution || Prefix Sum
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#include <vector>\n#include <queue>\n#include <utility>\n\nusing namespace std;\n\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        int n = nums.size();\n        int m = queries.size();\n        \n        vector<bool> marked(n, false);\n        \n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n        \n        long long unmarkedSum = 0;\n        for (int i = 0; i < n; ++i) {\n            if (!marked[i]) {\n                pq.push({nums[i], i});\n                unmarkedSum += nums[i];\n            }\n        }\n        \n        vector<long long> ans;\n        for (int i = 0; i < m; ++i) {\n            int index = queries[i][0];\n            int k = queries[i][1];\n            \n            if (!marked[index]) {\n                marked[index] = true;\n                unmarkedSum -= nums[index]; // Subtract the marked element\'s value from the unmarked sum\n            }\n            \n            while (k > 0 && !pq.empty()) {\n                auto [value, idx] = pq.top();\n                pq.pop();\n                \n                if (!marked[idx]) {\n                    marked[idx] = true;\n                    unmarkedSum -= value; // Subtract the marked element\'s value from the unmarked sum\n                    --k;\n                }\n            }\n            \n            ans.push_back(unmarkedSum);\n        }\n        \n        return ans;\n    }\n};\n\n```
['Heap (Priority Queue)', 'Prefix Sum', 'C++']