c++() 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    set<pair<int,int>> st;\n    long sum = 0;\n    vector<long long> ans;\n    \n    for(int i = 0; i != nums.size(); i++){\n      sum += nums[i];\n      st.insert({nums[i], i});\n    }\n\n    for(auto &q: queries)\n      if(st.size() == 0) ans.push_back(0);\n      else{\n        if(st.count({nums[q[0]], q[0]})) {sum -= nums[q[0]]; st.erase({nums[q[0]], q[0]});}\n        \n        for(int i = 0; i != q[1] && st.size() != 0; i++){\n          auto it = st.begin();\n          sum -= it->first;\n          st.erase(it);\n        }\n\n        ans.push_back(sum);\n      } \n\n    return ans;   \n  }\n};\n```
['C++']