C++ code using Heap
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: O(NlogN)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\nconst int mod=1e9+7;\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        int i,n=nums.size(),m=queries.size();\n        // long long sum=accumulate(nums.begin(),nums.end(),0),curr=0;\n        long long sum=0,curr=0;\n        // for(auto x: nums){\n        //     sum=(sum+x)%mod;\n        // }\n        vector<long long> ans;\n        \n        priority_queue<pair<int,int >,vector<pair<int ,int >>,greater<pair<int ,int >>> pq;\n        // priority_queue<pair<int,int>> pq;\n        \n        // for(auto x: nums) pq.push(x);\n        for(i=0;i<n;i++){\n            pq.push({nums[i],i});\n            sum+=nums[i];\n        }\n        \n        vector<bool> vis(n,false);\n        \n        for(auto q: queries){\n            int ind=q[0],k=q[1];\n            \n            if(!vis[ind]){\n                // curr+=nums[ind];\n                sum-=1ll*nums[ind];\n                vis[ind]=true;\n                \n            }\n            while(k>0 && !pq.empty()){\n                if(!vis[pq.top().second])\n               { sum-=1ll*pq.top().first;\n                vis[pq.top().second]=true;\n                 k--;\n                                                                 \n\n\n               }\n                pq.pop();\n\n               \n            }\n            \n            ans.push_back(sum);\n            curr=0;\n            \n            \n        }\n        \n        return ans;\n        \n    }\n};\n```
['C++']