RIP accepted 2min after ddl
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    public int maxFrequencyScore(int[] nums, long k) {\n        Arrays.sort(nums);\n        int res = 1;\n        int left = 0;\n        int right = 0;\n        int index = 0;\n        long cur = 0;\n        for(int i = 0; i<nums.length; i++){\n            int cIndex = (i+left)/2;\n            cur+=nums[i]-nums[index];\n            \n            if(index!=cIndex){\n                cur-=(nums[cIndex]-nums[index]);\n                index=cIndex;\n                \n            }\n            //if(i==2)System.out.println(cur);\n            while(cur>k && left<i){\n                cIndex=(i+left+1)/2;\n               \n                cur-=nums[index]-nums[left];\n                if(index!=cIndex){\n                    cur-=(nums[cIndex]-nums[index]);\n                    index=cIndex;\n                \n                }\n                left+=1;\n            }\n            //System.out.println(left);\n            res=Math.max(res,i-left+1);\n        }\n        return res;\n    }\n}\n```
['Java']