MARK NUM AS INT_MIN
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![image.png](https://assets.leetcode.com/users/images/7b891fc0-e6ce-4aa7-9b13-c252107ada03_1717772344.0595195.png)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        // SOLUTION OF TIN LE\n        ios_base::sync_with_stdio(false);\n        cin.tie(nullptr);\n        cout.tie(nullptr);\n        vector<long long> res;\n        long long sum = 0;\n        vector<pair<int, int>> list;\n        int n = nums.size();\n        for(int i = 0; i < nums.size(); i++)\n        {\n            sum += nums[i];\n            list.push_back({nums[i], i});\n        }\n        sort(list.begin(), list.end());\n        int start = 0;\n        for(auto& it : queries)\n        {\n            long index = it[0], amount = it[1], val = nums[it[0]];\n            if(nums[index] != INT_MIN)\n            {\n                sum -= val;\n                nums[index] = INT_MIN;\n            }\n            while(amount > 0 && start < list.size())\n            {\n                if(nums[list[start].second] != INT_MIN)\n                {\n                    nums[list[start].second] = INT_MIN;\n                    sum -= list[start].first;\n                    amount--;\n                }\n                start++;\n            }\n            res.push_back(sum);\n        }\n        return res;\n    }\n};\n```
['C++']