NiceSet

Time limit: 0.25s
Memory limit: 128MB
Input:
Output:

The Great Kagura loves the number S. In front of her, she has a sequence of integers a1,...,ana_1, ... , a_n. She wants to select a collection of these integers such that the sum of the absolute values of the differences of all pairs of integers in her collection is at most S. For example, if her collection is x, y, z, then |x − y| + |x − z| + |y − z| ≤ S. She wants to select the largest collection that she can. Can you help her?

Input Data

The first line of the input contains the two integers n and S. The second line of the input contains a1,...,ana_1, ... , a_n.

Output Data

Output the size of the largest collection of integers from among a1,...,ana_1, ... , a_n that satisfy the required condition.

Restrictions

  • 1 ≤ n ≤ 300 000
  • 1ai1 000 000 0001 ≤ a_i ≤ 1 \ 000 \ 000 \ 000
  • 1S10181 ≤ S ≤ 10^{18}

Subtask 1 (6 points)

  • ai=1a_i = 1

Subtask 2 (7 points)

  • ai{1,2}a_i ∈ \{1, 2\}

Subtask 3 (8 points)

  • ai=ia_i = i

Subtask 4 (9 points)

  • n ≤ 20
  • ai1 000a_i ≤ 1 \ 000
  • S ≤ 1 000 000 000

Subtask 5 (21 points)

  • n ≤ 100
  • S ≤ 1 000 000 000

Subtask 6 (18 points)

  • n ≤ 2000
  • S ≤ 1 000 000 000

Subtask 7 (31 points)

  • No further restrictions.

Examples

stdin

5 3
1 2 3 4 5

stdout

2

Explanation

One possible collection is 1, 2. All collections with 3 elements have the sum of absolute differences at least 4.

stdin

5 4
1 2 3 4 5

stdout

3

Explanation

One possible collection is 1, 2, 3.

stdin

5 1
1 1 1 1 1

stdout

5

Explanation

The entire sequence is a valid collection.

stdin

10 7
1 5 3 2 4 3 1 3 2 100

stdout

5

Explanation

One possible collection is 2, 2, 3, 3, 3.

Problem info

ID: 242

Editor: liviu

Author:

Source: infO(1) Cup 2022, Day 1

infO(1) Cup 2022, Day 1

Log in or sign up to be able to send submissions!