C++
\nclass Solution {\npublic:\n    vector<int> findXSum(vector<int>& nums, int k, int x) {\n        vector<int>rets;\n        for(int i = 0; i + k <= nums.size();
```\nclass Solution {\npublic:\n    vector<int> findXSum(vector<int>& nums, int k, int x) {\n        vector<int>rets;\n        for(int i = 0; i + k <= nums.size(); i++)\n            rets.push_back( helper(nums, k, x, i) );\n        return rets;\n    }\n    int helper(vector<int>& nums, int k, int x, int idx){\n        unordered_map<int, int>Map;\n        priority_queue<pair<int, int>>pq;\n        for(int i = 0; i < k; i++){\n            Map[nums[idx + i]]++;\n        }\n        for(auto [key, count] : Map){\n            pq.push({count, key});\n        }\n        int ret = 0;\n        int items = 0;\n        while(items < x && !pq.empty()){\n            ret += pq.top().second  * pq.top().first;\n            pq.pop();\n            items++;\n        }\n        return ret;\n    }\n};\n```
[]