Beats 100% | C++ | Priority_Queue | Easy ✅✅
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```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        int n = nums.size();\n        vector<long long> result;\n        long long tot = 0;\n        // Store the unmarked indices in a priority queue\n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n        for (int i = 0; i < n; ++i) {\n            //Store total sum\n            tot += nums[i];\n            if (nums[i] != -1) {\n                pq.push({nums[i], i});\n            }\n        }\n        \n        for (const auto& query : queries) {\n            int index = query[0];\n            int k = query[1];\n            \n            // Mark the element at index if it\'s not already marked\n            if (nums[index] != -1) {\n                // For marked element, remove that element from the total sum\n                tot -= nums[index];\n                nums[index] = -1;  \n            }\n            \n            // Mark k unmarked elements with the smallest values\n            while (k > 0 && !pq.empty()) {\n                auto [value, idx] = pq.top();\n                pq.pop();\n                if (nums[idx] != -1) {\n                    // For marked element, remove that element from the total sum\n                    tot -= nums[idx];\n                    nums[idx] = -1;\n                    k--;\n                }\n            }\n            result.push_back(tot);\n        }\n        \n        return result;\n    }\n};\n```
['C++']