Algorithm Based Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nWhen you read the problem and finaaly understand it after 50 attempts, the solution is 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWhen you read the problem and finaaly understand it after 50 attempts, the solution is quite simple just do what the question asks.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nMake a boolean array to keep tracked which index is marked which is not. \nYou are asked to mark the index if not the boolean array will help, in the second part you have to choose K UNMARKED SMALLEST ELEMENTS you can a min priority queue where your store the element and its index(WHY INDEX? ... BECAUSE IT WILL HELP YOU SEE IF THAT ELEMENT WHICH COMES OUT TO BE SMALLEST IS MARKED OR UNMARKED). Keep updating the sum at every query according and store it at the end in the ans array and return it.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N+M*K*log(N));\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N+N);\n\n# Code\n```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) \n    {\n        int n = nums.size();\n        int m = queries.size();\n\n        vector<bool> marked(n,false);\n        long long sum = 0;//sum fo all elements of the array\n        priority_queue<pair<int,int>,vector<pair<int,int> >, greater<pair<int,int> > > pq;//min pq\n          for(int i=0;i<n;i++)\n        {\n            pq.push({nums[i],i});\n            sum+=nums[i];\n        }\n\n        vector<long long> ans(m,0);\n\n        for(int i=0;i<m;i++)\n        {\n            vector<int> q = queries[i];\n            int index = q[0];\n            int k = q[1];\n\n            if(marked[index]==false)\n            {\n                marked[index] = true;\n                sum-=nums[index];\n            }\n            while(pq.size()>0 && k>0)\n            {\n                int idx = pq.top().second;\n                int ele = pq.top().first;\n                pq.pop();\n                if(marked[idx]==false)\n                {\n                    k--;\n                    sum-=ele;\n                    marked[idx] = true;\n                }\n            }\n            ans[i] = sum;\n        }\n        return ans;\n    }\n};\n```
['C++']