simple simulation || easy to understand || must see
Code\n\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n         \n         vector<long lo
# Code\n```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n         \n         vector<long long>ans;\n         vector<bool>marked(nums.size(),false);\n         long long int totalSum = 0;\n         for(int i = 0 ; i < nums.size() ; i++) totalSum = totalSum + 0LL + nums[i];\n         \n         priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n         for(int i = 0 ; i < nums.size() ; i++) pq.push({nums[i],i});\n\n         for(int i = 0 ; i < queries.size() ; i++){\n              int idx = queries[i][0];\n              int k   = queries[i][1];\n              \n              if(marked[idx] == false) {\n                    marked[idx] = true;\n                   totalSum = 0LL + totalSum - nums[idx];\n              }\n              while(pq.size() > 0 and k > 0){\n                 \n                   int ele = pq.top().first;\n                   int idx = pq.top().second;\n                   pq.pop();\n\n                   if(marked[idx] == false){\n                       marked[idx] = true;\n                       totalSum = 0LL + totalSum - ele;\n                       k--;\n                   }\n              }\n              ans.push_back(totalSum);\n         }\n         return ans;\n    }\n};\n```
['Array', 'Hash Table', 'Sorting', 'Simulation', 'C++']