Easy Implementation
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```\n#pragma GCC optimize("03","Ofast","inline","fast-math","unroll-loops","no-stack-protector","-ffast-math")\n#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native","f16c")\n#define pp pair<long,long>\nclass cmp\n{\npublic:\n    bool operator()(const pp& a,const pp& b)\n    {\n        if(a.first==b.first) return a.second > b.second;\n        return a.first > b.first;\n    }\n};\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n        vector<long long> ans;\n        vector<int> marked(nums.size(),0);\n\n        priority_queue<pp,vector<pp>,cmp> smallest_element;\n        long long sum=0;\n\n        for(int i=0;i<nums.size();i++)\n        {\n            sum+=nums[i];\n            smallest_element.push({nums[i],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            if(marked[index]==0) //unmarked\n            {\n                marked[index]=1;\n                if(sum!=0) sum -=nums[index];\n            }\n\n            while(!smallest_element.empty() and k>0)\n            {\n                auto[smallest_ele,smallest_index] = smallest_element.top(); smallest_element.pop();\n\n                if(marked[smallest_index]==0) //unmarked\n                {\n                    marked[smallest_index] =1;\n                    if(sum!=0) sum -= smallest_ele;\n                    k--;\n                }\n            }\n\n            ans.push_back(sum);\n        }\n        \n        return ans;\n    }\n};\n```
['Array', 'Heap (Priority Queue)', 'C++']