Under construction

Still being built. Things may change

Cat Cafe

Interview

Time limit2sMemory limit1024 MB

Summary
Pair up cats so each pair's total weight is at most K, and find the maximum number of pairs that can be formed.
Level

Easy3 of 10

Topics
Sorting, Two pointers, Greedy
Solved
No attempts yet

Problem

Chanwoo is going to a cat cafe with his friends.

The cat cafe has NN cats. The weight of the ii-th cat is w_iw\_i. Chanwoo and his friends all love cats, so each person becomes happy when they hold exactly 22 cats on their lap. However, Chanwoo and his frail friends cannot hold up if the total weight of the two cats they hold exceeds KK.

Given the weight of each cat and the maximum weight KK that one person can bear, find the maximum number of people who can be happy.

Input

The first line contains integers NN and KK, separated by a space. (1≤N≤5 0001 \leq N \leq 5\,000; 1≤K≤1091 \leq K \leq 10^9)

The second line contains NN integers w_1,w_2,⋯ ,w_Nw\_1, w\_2, \dotsm, w\_N, separated by spaces. (1≤w_i≤K1 \leq w\_i \leq K)

Output

Print the maximum number of people who can be happy.

Examples3

  1. Example 1

    Input
    5 20
    8 16 11 2 4
    
    Expected output
    2
    
  2. Example 2

    Input
    6 10
    9 5 6 7 4 3
    
    Expected output
    2
    
  3. Example 3

    Input
    4 100
    100 99 98 97
    
    Expected output
    0