C++ priority_queue
\'\'\'\n\n    vector findXSum(vector& nums, int k, int x) {\n        vector res;\n        int N = nums.size();\n        for (int i=0; i<N-k+1; ++i) {\n         
\'\'\'\n\n    vector<int> findXSum(vector<int>& nums, int k, int x) {\n        vector<int> res;\n        int N = nums.size();\n        for (int i=0; i<N-k+1; ++i) {\n            // now build the map/pq;\n            map<int, int> m;\n            priority_queue<pair<int, int>> pq;\n            for (int j=i; j<i+k; ++j) {\n                m[nums[j]]++;\n            }\n            for (auto it : m) {\n                pq.push({it.second, it.first});\n            }\n            int sum=0, count=x;\n            while (count>0 && !pq.empty()) {\n                --count;\n                pair<int, int> cur = pq.top();\n                pq.pop();\n                sum += (cur.first * cur.second);\n            }\n            res.push_back(sum);\n        }\n        return res;\n    }\n\n\'\'\'
[]