Using Priority Queue | Clean Code | C++
Intuition\n- This is an Simple Simulation Problem\n- Maintain a Priority Queue to get minimum unmarked elements\n- Also we need to maintain the marked Status an
# Intuition\n- This is an Simple Simulation Problem\n- Maintain a Priority Queue to get minimum unmarked elements\n- Also we need to maintain the marked Status and remaining Sum after each query\n\n# Code\n```\nclass Solution {\npublic:\n    using Data = pair<int,int>;\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries){\n\n        long long remaining = 0 , n = nums.size();\n\n        priority_queue<Data,vector<Data>,greater<Data>> pq;\n        for(int i=0;i<n;i++){\n            pq.push({nums[i],i});\n            remaining += nums[i];\n        }\n\n        vector<long long> ans , marked(n,0);\n\n        for(vector<int> &q : queries){\n            int id = q[0] , k = q[1];\n\n            if(!marked[id]){\n                marked[id] = 1;\n                remaining -= nums[id];\n            } \n\n            while(k && !pq.empty()){\n                Data p = pq.top();\n                pq.pop();\n                if(!marked[p.second]){\n                    marked[p.second] = 1;\n                    remaining -= nums[p.second];\n                    k--;\n                }\n            }\n\n            ans.push_back(remaining);\n        }\n\n        return ans;\n    }\n};\n```
['C++']