Beats 100% | C++ | Easy | with comment
Code\n\n/*\nTC : O(n.k.logn)\nSC : O(n)\n*/\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) 
# Code\n```\n/*\nTC : O(n.k.logn)\nSC : O(n)\n*/\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        vector<long long> ans; // SC:O(n)\n        \n        unordered_map<int,bool> mp; // map -> {idx,visited}, SC:O(n)\n        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq; // min heap --> {val,idx}, SC:O(n)\n        long long sum = 0;\n        for(int i = 0; i < nums.size(); i++) { // TC:O(n) * O(logn) = O(n.logn)\n            mp[i] = 0;\n            pq.push({nums[i],i});\n            sum += nums[i];\n        }\n        \n        for(auto query : queries) { // TC:O(n) * O(k.logn) = TC:O(n.k.logn)\n            int i = query[0];\n            int k = query[1];\n            \n            // 1st task\n            if(mp[i] == 0) {\n                mp[i] = 1;\n                sum -= nums[i];\n            }\n            \n            // 2nd task\n            while(!pq.empty() && k >= 1) { // TC:O(k.logn)\n                pair<int,int> top = pq.top();\n                pq.pop();\n                if(mp[top.second] == false && k >= 1) {\n                    // cout << top.first << " " << top.second << endl;\n                    sum -= top.first;\n                    mp[top.second] = 1;\n                    k--;\n                }\n            }\n            \n            ans.push_back(sum);\n        }\n        \n        return ans;\n    }\n};\n```
['Ordered Map', 'Heap (Priority Queue)', 'C++']