Priority queue || Set
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(), m=queries.size();\n        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n        set<int> st;\n\n        long long sum=0;\n        for(int i=0; i<n; i++){\n            pq.push({nums[i],i});\n            sum+=nums[i];\n        }\n\n        vector<long long> res;\n        for(int i=0; i<m; i++){\n            int index = queries[i][0];\n            int k = queries[i][1];\n            if(st.find(index)==st.end()){\n                st.insert(index);\n                sum-=nums[index];\n            }\n            \n            while(!pq.empty() && k>0){\n                auto p = pq.top(); pq.pop();\n                int num = p.first, ind = p.second;\n                if(st.find(ind)==st.end()){\n                    sum-=num;\n                    st.insert(ind);\n                    k--;\n                }\n                if(sum<0) sum=0;\n            }\n            res.push_back(sum);\n        }\n        return res;\n    }\n};\n```
['Heap (Priority Queue)', 'Ordered Set', 'C++']