Brute force
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\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> findXSum(vector<int>& nums, int k, int x) {\n        vector<int>ans;\n        unordered_map<int,int>map;\n        int n=0;\n        int start=0,end=0;\n        while(end<nums.size()){\n            map[nums[end]]++;\n            n++;\n            if(n==k){\n                vector<pair<int,int>>temp;\n                for(auto ele : map) temp.push_back({ele.first, ele.second});\n                for(int i=0; i<temp.size(); i++){\n                    for(int j=0; j<temp.size()-1-i; j++){\n                        if(temp[j].second==temp[j+1].second && temp[j].first<temp[j+1].first) swap(temp[j],temp[j+1]);\n                        else if(temp[j].second<temp[j+1].second) swap(temp[j],temp[j+1]);\n                    }\n                }\n                for(auto ele : temp) cout<<ele.first<<" "<<ele.second<<endl;\n                int sum=0;\n                for(int i=0,j=0; i<temp.size() && j<x; i++,j++){\n                    sum+=temp[i].first*temp[i].second;\n                }\n                ans.push_back(sum);\n                n--;\n                map[nums[start]]--;\n                if(map[nums[start]]==0) map.erase(nums[start]);\n                start++;\n            }\n            end++;\n        }\n        return ans;\n    }\n};\n```
['Ordered Map', 'Sliding Window', 'C++']