c++ | priority queue | 85% faster than all
```\nclass Solution {\npublic:\n    long long kSum(vector& nums, int k) {\n        long long sum = 0;\n        for(int i=0; i=0) sum+=nums[i];\n            else
```\nclass Solution {\npublic:\n    long long kSum(vector<int>& nums, int k) {\n        long long sum = 0;\n        for(int i=0; i<nums.size(); ++i) {\n            if(nums[i]>=0) sum+=nums[i];\n            else nums[i]*=-1;\n        }\n        sort(nums.begin(), nums.end());\n        typedef pair<long long, int> p;\n        priority_queue<p> pq;\n        pq.push({sum-nums[0], 0});\n        long long ans = sum;\n        while(!pq.empty() && k>1) {\n            p curr = pq.top();\n            pq.pop();\n            sum = curr.first;\n            int i = curr.second;\n            if(i<nums.size()-1) {\n                pq.push({sum+nums[i]-nums[i+1], i+1});\n                pq.push({sum-nums[i+1], i+1});\n            }\n            k--;\n            ans = sum;\n        }\n     return ans;\n    }\n};
[]