Suboptimal solution
Intuition\n Describe your first thoughts on how to solve this problem. \nWe use the fixed-size sliding window pattern, in addition to using a hash map in order 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe use the fixed-size sliding window pattern, in addition to using a hash map in order to keep track of numbers and frequencies. \n\nWe initialize the numbers and frequencies for our first window.\n\nThen we loop for as long as our right pointer is still in our list.\n\nAt each loop, we get our key, value tuples for nums, freqs. We then first sort it by number size, and then by frequency, in decreasing order. We do first by number value, so that in case of draw, we get the largest one. Because next we slice the list at x.\n\nThen we simply iterate through the remaining pairs and sum up the (value*freq)\'s, and append to our sums list.\n\nLastly we update our left and right pointer, remembering to decrease the frequency by one for the number at our left pointer, and adding one to the right pointer.\n\nThen we return our sum.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: Would be O(n), but since we sort, it\'s O(log(n)), but input sizes are at max 50, so thats fine, as 50*log(50) = 85.\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```python []\nclass Solution(object):\n    def findXSum(self, nums, k, x):\n        """\n        :type nums: List[int]\n        :type k: int\n        :type x: int\n        :rtype: List[int]\n        """\n        lp = 0\n        rp = k-1\n        freq = {}\n        sums = []\n\n        for i in range(k):\n            if nums[i] in freq:\n                freq[nums[i]] += 1\n            else:\n                freq[nums[i]] = 1\n\n        while rp <= len(nums)-1:\n            curr_freqs = freq.items()\n            curr_freqs.sort(key=lambda x: -x[0])\n            curr_freqs.sort(key=lambda x: -x[1])\n            curr_freqs = curr_freqs[:x]\n            curr_sum = 0\n            for num, freq_val in curr_freqs:\n                curr_sum += num*freq_val\n            sums.append(curr_sum)\n            freq[nums[lp]] = max(freq[nums[lp]]-1, 0)\n            lp += 1\n            rp += 1\n            if rp > len(nums)-1:\n                return sums\n            if nums[rp] in freq:\n                freq[nums[rp]] += 1\n            else:\n                freq[nums[rp]] = 1\n        return sums\n```
['Python']