Easy Intuitive C++ solution
\n\n# Code\n\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        vector<pair<int,int>
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        vector<pair<int,int>>v; //num,location\n        long long unmarked_sum=0;\n        int n=nums.size();\n        int unmarked=n;\n        for(int i=0;i<n;i++){\n            unmarked_sum+=nums[i];\n            v.push_back({nums[i],i});\n        }\n        sort(v.begin(),v.end());\n        vector<bool>marked(n,false);\n        vector<long long>ans;\n        int v_index=0;\n        for(auto i:queries){\n            int index=i[0];\n            int k=i[1];\n            if(!marked[index]){\n                marked[index]=true;\n                unmarked_sum-=nums[index];\n                unmarked--;\n            }\n            for(int j=0;j<k && unmarked>0;j++){\n                while(marked[v[v_index].second]){\n                    v_index++;\n                }\n                unmarked_sum-=v[v_index].first;\n                marked[v[v_index].second]=true;\n                v_index++;\n                unmarked--;\n            }\n            ans.push_back(unmarked_sum);\n        }\n        return ans;\n    }\n};\n```
['C++']