PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000160. Tối đa tần suất bằng phép tăng giảm (Apply Operations to Maximize Frequency Score)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tối đa tần suất bằng phép tăng giảm (Apply Operations to Maximize Frequency Score)

Apply Operations to Maximize Frequency Score

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array of nn positive integers and a budget kk, you may increment or decrement one chosen element by exactly 11 in each operation, performing at most kk operations. The score of the resulting array is the maximum frequency of any value. Find the greatest possible score.

Input

  • The first line contains n,kn,k.
  • The second line contains nn integers a1,…,ana_1,\ldots,a_n.

Output

Print the largest achievable frequency after at most kk operations.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30; 1≤ai≤1091\le a_i\le 10^9; 0≤k≤10140\le k\le 10^{14}.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 1≤ai≤1091\le a_i\le 10^9; 0≤k≤10140\le k\le 10^{14}.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le 10^5; 1≤ai≤1091\le a_i\le 10^9; 0≤k≤10140\le k\le 10^{14}.

Examples

Input

4 3
1 2 6 4

Output

3

Explanation

With [1,2,6,4][1,2,6,4] and k=3k=3, raise 11 to 22 (one operation), and lower 44 to 22 (two operations). This yields [2,2,6,2][2,2,6,2], so the answer is 3. Making all four elements equal would require more than three operations.