Under construction

Still being built. Things may change

Fireworks

Interview

Time limit1sMemory limit1024 MB

Summary
Given firecracker brilliances and a threshold K, find the most shows you can build from single or paired firecrackers, each at least K and in non-decreasing order.
Level

Medium5 of 10

Topics
Greedy, Sorting, Two pointers
Solved
No attempts yet

Problem

INU Code Festival ends with a fireworks show. Gwangjae is in charge of this year's fireworks.

Someone bought up all the firecrackers, so the show has to be built from the remaining NN firecrackers.

Each firecracker has an integer AiA_i that gives its brilliance. Arrange the show so that it satisfies the following rules. You do not have to use every firecracker.

  1. The brilliance of the first show must be at least KK.
  2. The brilliance of each show is not less than the brilliance of the previous show.
  3. For safety, you can set off only 1 or 2 firecrackers at a time. If you set off 2 at once, the brilliance is the sum of the two.

For example, suppose the remaining firecrackers have brilliance 10,4,1,8,12,510, 4, 1, 8, 12, 5 and the first show must have brilliance at least 77. Then the show can proceed as follows while satisfying the rules.

8→(4+5)→10→128 → (4+5) → 10 → 12

This gives 4 shows. No sequence can satisfy the rules with more shows.

If the remaining firecrackers have brilliance 2,32, 3 and the first show must have brilliance at least 77, the show cannot satisfy the rules.

Students enjoy the show more when there are more shows. Help Gwangjae build as many shows as possible.

If at least one show can be held, print the maximum number of shows. If no show can be held, print −1-1.

Input

The first line contains NN and KK. (1≤N≤2000001 \le N \le 200000, 1≤K≤1091 \le K \le 10^9, KK is an integer.)

The second line contains NN integers A1,A2,…,ANA_1, A_2, \ldots, A_N separated by spaces, the brilliance of each firecracker. (1≤Ai≤1091 \le A_i \le 10^9)

Output

Print the maximum number of shows that can be held. If no show can be held, print −1-1.

Examples2

  1. Example 1

    Input
    6 7
    10 4 1 8 12 5
    
    Expected output
    4
    
  2. Example 2

    Input
    2 7
    2 3
    
    Expected output
    -1