Beats 100% Time and Space ✅🤩| Using 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        long long int sum = 0;                        \n        vector<long long> ans;\n        multiset<pair<int,int>> s;\n        for(int i=0 ; i<nums.size() ; i++)\n        {\n            s.insert({nums[i] , i});\n            sum += nums[i];\n        }       \n        \n        for(int i=0 ; i<queries.size() ; i++)\n        {\n            int index = queries[i][0];\n            int k = queries[i][1];\n            \n            pair<int,int> p = make_pair(nums[index],index);\n            if(s.find(p) != s.end()){\n                s.erase(p);\n                sum -= nums[index];\n            }            \n            if(s.size() < k && sum == 0){   // If unmarked less than k mark them all \n                sum = 0;\n                ans.push_back(sum);                  \n                continue;\n            }                       \n            for(auto it:s)\n            {\n                if(k){\n                    sum -= it.first;\n                    s.erase(it);\n                }\n                else{\n                    break;\n                }\n                k--;\n            }            \n            ans.push_back(sum);\n        }\n        \n        return ans;\n    }\n};\n```
['Ordered Set', 'C++']