CPP || USING MIN HEAP || SET
Approach: Simply keep all elements in a min priority queue with index , intuition behind taking a min priority queue was because " In each query we have to enco
Approach: Simply keep all elements in a min priority queue with index , intuition behind taking a min priority queue was because " In each query we have to encounter minimum values from array".\nNow you just have to do whats written in problem statements and query. \nUse a SET to differentiate betwwen marked and unmarked.\n\n```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        vector<long long > res;\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;\n        set<int> marked;\n        long long unmSum=0;\n        for(int i=0;i<nums.size();i++){\n            unmSum+=nums[i];\n            pq.push({nums[i],i});\n        }\n        \n        for(auto q:queries){\n            int ci=q[0];\n            int k=q[1];\n           if(marked.count(ci)==0){ unmSum-=nums[ci];\n            marked.insert(ci);\n                                  }\n            while(pq.size() && k>0){\n                pair<int,int> tp=pq.top();\n                pq.pop();\n                if(marked.count(tp.second)==0){\n                    // cout<<tp.second<<" ";\n                    unmSum-=tp.first;\n                    k--;\n                    marked.insert(tp.second);\n                }\n                \n                if(unmSum<0) unmSum=0;\n            }\n            // cout<<endl;\n            res.push_back(unmSum);\n        }\n        return res;\n        \n    }\n};****\n```
['C', 'C++']