simple python solution, create hashmap first -> sort hashmap by key desc -> get value from max key
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def findXSum(self, nums: List[int], k: int, x: int) -> List[int]:
        n = len(nums)
        ans=[]

        for i in range(n-k+1):
            t = nums[i:i+k]
            hashmap = {}
            for j in t:
                if j not in hashmap:
                    hashmap[j] = 1
                else:
                    hashmap[j] += 1
            hashmap = dict(sorted(hashmap.items(),reverse=True))
            cnt=0
            for j in range(x):
                try:
                    v = max(hashmap, key=hashmap.get)
                    cnt+=(v*hashmap[v])
                    hashmap.pop(v)
                except ValueError:
                    pass
            ans.append(cnt) 
        return ans        
```
['Python3']