Python 3 || 9 lines,  two pointers || T/S: 70% / 73%
\nclass Solution:\n    def maxFrequencyScore(self, nums: List[int], k: int) -> int:\n        \n        notValid = lambda l, n: (acc[l] + acc[n-l] - 2*acc[n//2] 
```\nclass Solution:\n    def maxFrequencyScore(self, nums: List[int], k: int) -> int:\n        \n        notValid = lambda l, n: (acc[l] + acc[n-l] - 2*acc[n//2] - \n                                                 nums[n//2]*(n%2) > k)\n\n        nums.sort()\n        acc = list(accumulate(nums, initial = 0))\n        left = ans = 0\n\n        for rght in range(len(nums)):\n            while notValid(left, left+rght+1): left+= 1\n            ans = max(ans, rght - left)\n           \n        return ans+1\n```\n[https://leetcode.com/problems/apply-operations-to-maximize-frequency-score/submissions/1295792677/](https://leetcode.com/problems/apply-operations-to-maximize-frequency-score/submissions/1295792677/)\n\nI could be wrong, but I think that time complexity is *O*(*N* log *N*) and space complexity is *O*(*N*), in which *N* ~ `len(nums)`.
['Python3']