Check valid range [left, right]
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```\nclass Solution:\n    def maxFrequencyScore(self, nums: List[int], k: int) -> int:\n        n = len(nums)\n        nums.sort()\n        acc=[0]+list(accumulate(nums))\n        def feasible(left,right):\n            mid = (left+right)//2\n            return (mid-left)*nums[mid] - (acc[mid]-acc[left]) + (acc[right+1]-acc[mid]) - (right-mid+1) * nums[mid] <= k\n        left=right=res=0\n        while right<n:\n            if feasible(left,right):\n                res=max(res, right-left+1)\n                right+=1\n            else: left+=1\n        return res\n        \n```
['Python3']