C++ Solution using Min heap
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nUse a priority queue (min heap) which can store pair pf pairs in form ({n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nUse a priority queue (min heap) which can store pair pf pairs in form **({nums[i], index}, nums[i]})** this is done because the question clearly mentions that if there are mutliple elements of the same value,they should be marked on basis of their indieces(smallest first). This creates a min heap and the values are stored in the either on the basis of nums[i] or index(if equal elements present)\n\nPre **calculate the total sum (initially all the elements are unmarked** and with each iteration over queries array, **some elements will be marked, so we can subtract nums[queries[i][0]] when its there directly and then when we are marking the queries[i][1] elements too**.\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) {\npriority_queue<pair<pair<int,int>,int>,vector<pair<pair<int,int>,int>>,greater<pair<pair<int,int>,int>>>pq;\n        int n = nums.size();\n        vector<int> marked(n, 0);\n        vector<long long> res;\n        //calculate the sum of all the umarked(initially all)elements\n         long long sum = 0;\n            for (int i = 0; i < n; i++) {\n                    sum += nums[i]; }\n\n        for (int i = 0; i < n; i++) {\n            pq.push({{nums[i], i}, nums[i]});\n        }\n        for (int i = 0; i < queries.size(); i++) {\n            if(marked[queries[i][0]]==0){\n            marked[queries[i][0]] = 1; \n            sum-=nums[queries[i][0]];}\n            int k = 0;\n            while (!pq.empty() && k <queries[i][1]) {\n                int ind=pq.top().first.second;\n                pq.pop();\n                if(marked[ind]==0){\n                marked[ind]=1;\n                sum-=nums[ind];\n                k++;}\n                }\n            res.push_back(sum); // Push the sum to the result vector\n        }\n        return res;\n    }\n};\n\n```
['Heap (Priority Queue)', 'C++']