C++ || 100% beat (time complexity) || 100% beat space complexity
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        \n        multiset<pair<int,int>>st;\n        vector<long long>ans;\n        long long total=0;\n        for(int i=0;i<nums.size();i++){\n            st.insert({nums[i],i});\n            total+=nums[i];\n        }\n         \n        for(auto ite:queries){\n            int ind=ite[0];\n            int k=ite[1];\n            auto it= st.find({nums[ind],ind});\n            if(it!=st.end()){\n                st.erase(it);\n                total-=nums[ind];\n            }\n            while(k>0 && !st.empty()){\n                auto it=st.begin();\n                pair<int,int> vec=*it;\n                total-=vec.first;\n                st.erase(it);\n                k--;\n            }\n            \n            ans.push_back(total);\n        }\n           return ans;\n    }\n};\n```
['C++']